Skip to content

Commit 692305e

Browse files
ttaylorrgitster
authored andcommitted
midx.c: clean up chunkfile after reading the MIDX
In order to read the contents of a MIDX, we initialize a chunkfile structure which can read the table of contents and assign pointers into different sections of the file for us. We do call free(), since the chunkfile struct is heap allocated, but not the more appropriate free_chunkfile(), which also frees memory that the structure itself owns. Call that instead to avoid leaking memory in this function. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9d530dc commit 692305e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

midx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,13 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
179179
trace2_data_intmax("midx", the_repository, "load/num_packs", m->num_packs);
180180
trace2_data_intmax("midx", the_repository, "load/num_objects", m->num_objects);
181181

182+
free_chunkfile(cf);
182183
return m;
183184

184185
cleanup_fail:
185186
free(m);
186187
free(midx_name);
187-
free(cf);
188+
free_chunkfile(cf);
188189
if (midx_map)
189190
munmap(midx_map, midx_size);
190191
if (0 <= fd)

0 commit comments

Comments
 (0)