Skip to content

Commit e6432e0

Browse files
ttaylorrgitster
authored andcommitted
builtin/repack.c: avoid leaking child arguments
`git repack` invokes a handful of child processes: one to write the actual pack, and optionally ones to repack promisor objects and update the MIDX. Most of these are freed automatically by calling `start_command()` (which invokes it on error) and `finish_command()` which calls it automatically. But repack_promisor_objects() can initialize a child_process, populate its array of arguments, and then return from the function before even calling start_command(). Make sure that the prepared list of arguments is freed by calling child_process_clear() ourselves to avoid leaking memory along this path. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9e39acc commit e6432e0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/repack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,11 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
258258
for_each_packed_object(write_oid, &cmd,
259259
FOR_EACH_OBJECT_PROMISOR_ONLY);
260260

261-
if (cmd.in == -1)
261+
if (cmd.in == -1) {
262262
/* No packed objects; cmd was never started */
263+
child_process_clear(&cmd);
263264
return;
265+
}
264266

265267
close(cmd.in);
266268

0 commit comments

Comments
 (0)