Skip to content

Commit c3e76dd

Browse files
committed
odb: conditional git_hash_ctx_cleanup in git_odb_stream
When `git_odb_stream` is a read stream, `hash_ctx` is not used. Therefore, check if `hash_ctx` can be freed during the release. This allows implementers of custom ODB backends to not worry about the creation of `hash_ctx` for now.
1 parent 4ce872a commit c3e76dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libgit2/odb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,8 @@ void git_odb_stream_free(git_odb_stream *stream)
17961796
if (stream == NULL)
17971797
return;
17981798

1799-
git_hash_ctx_cleanup(stream->hash_ctx);
1799+
if (stream->hash_ctx)
1800+
git_hash_ctx_cleanup(stream->hash_ctx);
18001801
git__free(stream->hash_ctx);
18011802
stream->free(stream);
18021803
}

0 commit comments

Comments
 (0)