Commit 1dc89aab by Edward Thomson

object validation: free some memleaks

parent 34c13106
...@@ -205,6 +205,11 @@ static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len) ...@@ -205,6 +205,11 @@ static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len)
return inflate(s, 0); return inflate(s, 0);
} }
static void abort_inflate(z_stream *s)
{
inflateEnd(s);
}
static int finish_inflate(z_stream *s) static int finish_inflate(z_stream *s)
{ {
int status = Z_OK; int status = Z_OK;
...@@ -367,6 +372,7 @@ static int inflate_disk_obj(git_rawobj *out, git_buf *obj) ...@@ -367,6 +372,7 @@ static int inflate_disk_obj(git_rawobj *out, git_buf *obj)
(used = get_object_header(&hdr, head)) == 0 || (used = get_object_header(&hdr, head)) == 0 ||
!git_object_typeisloose(hdr.type)) !git_object_typeisloose(hdr.type))
{ {
abort_inflate(&zs);
giterr_set(GITERR_ODB, "failed to inflate disk object"); giterr_set(GITERR_ODB, "failed to inflate disk object");
return -1; return -1;
} }
......
...@@ -116,6 +116,7 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void) ...@@ -116,6 +116,7 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
cl_git_pass(git_object_lookup(&object, g_repo, &oid, GIT_OBJ_COMMIT)); cl_git_pass(git_object_lookup(&object, g_repo, &oid, GIT_OBJ_COMMIT));
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 1));
git_object_free(object);
git_buf_free(&oldpath); git_buf_free(&oldpath);
git_buf_free(&newpath); git_buf_free(&newpath);
} }
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