Skip to content

Commit 7f4c350

Browse files
ttaylorrgitster
authored andcommitted
t/helper/test-read-midx.c: free MIDX within read_midx_file()
When calling `read_midx_file()` to show information about a MIDX or list the objects contained within it we fail to call `close_midx()`, leaking the memory allocated to store that MIDX. Fix this by calling `close_midx()` before exiting the function. We can drop the "early" return when `show_objects` is non-zero, since the next instruction is also a return. (We could just as easily put a `cleanup` label here as with previous patches. But the only other time we terminate the function early is when we fail to load a MIDX in the first place. `close_midx()` does handle a NULL argument, but the extra complexity is likely not warranted). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 492cb39 commit 7f4c350

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

t/helper/test-read-midx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ static int read_midx_file(const char *object_dir, int show_objects)
5555
printf("%s %"PRIu64"\t%s\n",
5656
oid_to_hex(&oid), e.offset, e.p->pack_name);
5757
}
58-
return 0;
5958
}
6059

60+
close_midx(m);
61+
6162
return 0;
6263
}
6364

0 commit comments

Comments
 (0)