diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-11-29 23:41:49 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-11-29 23:41:49 (GMT) |
commit | 49767c3d9f80c916c175adfc745e0823487d9d08 (patch) | |
tree | eeff328ee4dc916e14a336abfb2cd8c79a6b346b /builtin | |
parent | 7c2abf1a83efa13ffc03a3847f774cf85ffce913 (diff) | |
parent | 655b8561d6b10f22f0e7350df9388110667001af (diff) | |
download | git-49767c3d9f80c916c175adfc745e0823487d9d08.zip git-49767c3d9f80c916c175adfc745e0823487d9d08.tar.gz git-49767c3d9f80c916c175adfc745e0823487d9d08.tar.bz2 |
Merge branch 'tb/plug-pack-bitmap-leaks'
Leakfix.
* tb/plug-pack-bitmap-leaks:
pack-bitmap.c: more aggressively free in free_bitmap_index()
pack-bitmap.c: don't leak type-level bitmaps
midx.c: write MIDX filenames to strbuf
builtin/multi-pack-index.c: don't leak concatenated options
builtin/repack.c: avoid leaking child arguments
builtin/pack-objects.c: don't leak memory via arguments
t/helper/test-read-midx.c: free MIDX within read_midx_file()
midx.c: don't leak MIDX from verify_midx_file
midx.c: clean up chunkfile after reading the MIDX
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/multi-pack-index.c | 4 | ||||
-rw-r--r-- | builtin/pack-objects.c | 11 | ||||
-rw-r--r-- | builtin/repack.c | 4 |
3 files changed, 14 insertions, 5 deletions
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c index 075d15d..4480ba3 100644 --- a/builtin/multi-pack-index.c +++ b/builtin/multi-pack-index.c @@ -167,6 +167,8 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv) usage_with_options(builtin_multi_pack_index_verify_usage, options); + FREE_AND_NULL(options); + return verify_midx_file(the_repository, opts.object_dir, opts.flags); } @@ -191,6 +193,8 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv) usage_with_options(builtin_multi_pack_index_expire_usage, options); + FREE_AND_NULL(options); + return expire_midx_packs(the_repository, opts.object_dir, opts.flags); } diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 1a3dd44..857be78 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -4148,11 +4148,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) read_packs_list_from_stdin(); if (rev_list_unpacked) add_unreachable_loose_objects(); - } else if (!use_internal_rev_list) + } else if (!use_internal_rev_list) { read_object_list_from_stdin(); - else { + } else { get_object_list(rp.nr, rp.v); - strvec_clear(&rp); } cleanup_preferred_base(); if (include_tag && nr_result) @@ -4162,7 +4161,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) the_repository); if (non_empty && !nr_result) - return 0; + goto cleanup; if (nr_result) { trace2_region_enter("pack-objects", "prepare-pack", the_repository); @@ -4183,5 +4182,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) " pack-reused %"PRIu32), written, written_delta, reused, reused_delta, reuse_packfile_objects); + +cleanup: + strvec_clear(&rp); + return 0; } diff --git a/builtin/repack.c b/builtin/repack.c index 0b2d1e5..9b74e0d 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); |