Commit 82209544 by Joe Rabinoff Committed by Edward Thomson

Fix segfault in loose_backend__readstream

If the routine exits with error before stream or hash_ctx is initialized, the
program will segfault when trying to free them.
parent c3b2053d
...@@ -1028,11 +1028,16 @@ static int loose_backend__readstream( ...@@ -1028,11 +1028,16 @@ static int loose_backend__readstream(
done: done:
if (error < 0) { if (error < 0) {
git_futils_mmap_free(&stream->map); if(stream && stream->map.data)
git_zstream_free(&stream->zstream); git_futils_mmap_free(&stream->map);
git_hash_ctx_cleanup(hash_ctx); if(stream)
git__free(hash_ctx); git_zstream_free(&stream->zstream);
git__free(stream); if(stream)
git__free(stream);
if(hash_ctx) {
git_hash_ctx_cleanup(hash_ctx);
git__free(hash_ctx);
}
} }
git_buf_free(&object_path); git_buf_free(&object_path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment