summaryrefslogtreecommitdiff
path: root/src/odb_loose.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-12-06 12:59:17 -0800
committerGitHub <noreply@github.com>2018-12-06 12:59:17 -0800
commitda8138b01217824cf211fa491608a7b067cf8e43 (patch)
tree6514538787d23d02c34967d0a78e3ad03fefff8e /src/odb_loose.c
parent8092c4315b1cf2c817bcb4c549216a647c9d6871 (diff)
parent2f3c4b69c96cf7f5b23c06c056ed4636932d80c0 (diff)
downloadlibgit2-da8138b01217824cf211fa491608a7b067cf8e43.tar.gz
Merge pull request #4906 from QBobWatson/bugfix
Fix segfault in loose_backend__readstream
Diffstat (limited to 'src/odb_loose.c')
-rw-r--r--src/odb_loose.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 3c0ed674d..12607dd38 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -1028,11 +1028,15 @@ static int loose_backend__readstream(
done:
if (error < 0) {
- git_futils_mmap_free(&stream->map);
- git_zstream_free(&stream->zstream);
- git_hash_ctx_cleanup(hash_ctx);
- git__free(hash_ctx);
- git__free(stream);
+ if (stream) {
+ git_futils_mmap_free(&stream->map);
+ git_zstream_free(&stream->zstream);
+ git__free(stream);
+ }
+ if (hash_ctx) {
+ git_hash_ctx_cleanup(hash_ctx);
+ git__free(hash_ctx);
+ }
}
git_buf_dispose(&object_path);