summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2017-05-01 21:34:21 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2017-05-01 22:55:12 +0100
commit1dc89aab24ef157dff033a86b5d6c429df61f48d (patch)
tree4315ccb8199dd433781dc7b5b38f03f344071a11
parent34c131062412480abd87ab825c2cd6c1b691e5f5 (diff)
downloadlibgit2-ethomson/memleak.tar.gz
object validation: free some memleaksethomson/memleak
-rw-r--r--src/odb_loose.c6
-rw-r--r--tests/object/lookup.c1
2 files changed, 7 insertions, 0 deletions
diff --git a/src/odb_loose.c b/src/odb_loose.c
index e14af4fab..a97ac25eb 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -205,6 +205,11 @@ static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len)
return inflate(s, 0);
}
+static void abort_inflate(z_stream *s)
+{
+ inflateEnd(s);
+}
+
static int finish_inflate(z_stream *s)
{
int status = Z_OK;
@@ -367,6 +372,7 @@ static int inflate_disk_obj(git_rawobj *out, git_buf *obj)
(used = get_object_header(&hdr, head)) == 0 ||
!git_object_typeisloose(hdr.type))
{
+ abort_inflate(&zs);
giterr_set(GITERR_ODB, "failed to inflate disk object");
return -1;
}
diff --git a/tests/object/lookup.c b/tests/object/lookup.c
index 277e2e0c0..544f32bc4 100644
--- a/tests/object/lookup.c
+++ b/tests/object/lookup.c
@@ -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_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 1));
+ git_object_free(object);
git_buf_free(&oldpath);
git_buf_free(&newpath);
}