Skip to content

Commit 1dc89aa

Browse files
committed
object validation: free some memleaks
1 parent 34c1310 commit 1dc89aa

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/odb_loose.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len)
205205
return inflate(s, 0);
206206
}
207207

208+
static void abort_inflate(z_stream *s)
209+
{
210+
inflateEnd(s);
211+
}
212+
208213
static int finish_inflate(z_stream *s)
209214
{
210215
int status = Z_OK;
@@ -367,6 +372,7 @@ static int inflate_disk_obj(git_rawobj *out, git_buf *obj)
367372
(used = get_object_header(&hdr, head)) == 0 ||
368373
!git_object_typeisloose(hdr.type))
369374
{
375+
abort_inflate(&zs);
370376
giterr_set(GITERR_ODB, "failed to inflate disk object");
371377
return -1;
372378
}

tests/object/lookup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
116116
cl_git_pass(git_object_lookup(&object, g_repo, &oid, GIT_OBJ_COMMIT));
117117
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 1));
118118

119+
git_object_free(object);
119120
git_buf_free(&oldpath);
120121
git_buf_free(&newpath);
121122
}

0 commit comments

Comments
 (0)