Skip to content

Commit 492cb39

Browse files
ttaylorrgitster
authored andcommitted
midx.c: don't leak MIDX from verify_midx_file
The function midx.c:verify_midx_file() allocates a MIDX struct by calling load_multi_pack_index(). But when cleaning up, it calls free() without freeing any resources associated with the MIDX. Call the more appropriate close_midx() which does free those resources, which causes t5319.3 to pass when Git is compiled with SANITIZE=leak. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 692305e commit 492cb39

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

midx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
16031603
* Remaining tests assume that we have objects, so we can
16041604
* return here.
16051605
*/
1606-
return verify_midx_error;
1606+
goto cleanup;
16071607
}
16081608

16091609
if (flags & MIDX_PROGRESS)
@@ -1681,7 +1681,9 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
16811681
}
16821682
stop_progress(&progress);
16831683

1684+
cleanup:
16841685
free(pairs);
1686+
close_midx(m);
16851687

16861688
return verify_midx_error;
16871689
}

0 commit comments

Comments
 (0)