Skip to content

Commit da8138b

Browse files
authored
Merge pull request libgit2#4906 from QBobWatson/bugfix
Fix segfault in loose_backend__readstream
2 parents 8092c43 + 2f3c4b6 commit da8138b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/odb_loose.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,11 +1028,15 @@ static int loose_backend__readstream(
10281028

10291029
done:
10301030
if (error < 0) {
1031-
git_futils_mmap_free(&stream->map);
1032-
git_zstream_free(&stream->zstream);
1033-
git_hash_ctx_cleanup(hash_ctx);
1034-
git__free(hash_ctx);
1035-
git__free(stream);
1031+
if (stream) {
1032+
git_futils_mmap_free(&stream->map);
1033+
git_zstream_free(&stream->zstream);
1034+
git__free(stream);
1035+
}
1036+
if (hash_ctx) {
1037+
git_hash_ctx_cleanup(hash_ctx);
1038+
git__free(hash_ctx);
1039+
}
10361040
}
10371041

10381042
git_buf_dispose(&object_path);

0 commit comments

Comments
 (0)