diff options
author | Taylor Blau <me@ttaylorr.com> | 2021-10-28 16:25:48 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-10-28 15:31:51 -0700 |
commit | e6432e0f1f183595b265b76ca765c612e705c65a (patch) | |
tree | 143f39d8cf8ca086885e8ea03493ca66c8c40c0a | |
parent | builtin/pack-objects.c: don't leak memory via arguments (diff) | |
download | tgif-e6432e0f1f183595b265b76ca765c612e705c65a.tar.xz |
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 <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/repack.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/repack.c b/builtin/repack.c index 0b2d1e5d82..9b74e0d468 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -258,9 +258,11 @@ static void repack_promisor_objects(const struct pack_objects_args *args, for_each_packed_object(write_oid, &cmd, FOR_EACH_OBJECT_PROMISOR_ONLY); - if (cmd.in == -1) + if (cmd.in == -1) { /* No packed objects; cmd was never started */ + child_process_clear(&cmd); return; + } close(cmd.in); |