t/helper: fix leaking multi-pack-indices in "read-midx"
Several of the subcommands of `test-helper read-midx` do not close the MIDX that they have opened, leading to memory leaks. Fix those. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
bda97cb119
commit
fb24460e1d
@ -86,6 +86,8 @@ static int read_midx_checksum(const char *object_dir)
|
|||||||
if (!m)
|
if (!m)
|
||||||
return 1;
|
return 1;
|
||||||
printf("%s\n", hash_to_hex(get_midx_checksum(m)));
|
printf("%s\n", hash_to_hex(get_midx_checksum(m)));
|
||||||
|
|
||||||
|
close_midx(m);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +104,12 @@ static int read_midx_preferred_pack(const char *object_dir)
|
|||||||
|
|
||||||
if (midx_preferred_pack(midx, &preferred_pack) < 0) {
|
if (midx_preferred_pack(midx, &preferred_pack) < 0) {
|
||||||
warning(_("could not determine MIDX preferred pack"));
|
warning(_("could not determine MIDX preferred pack"));
|
||||||
|
close_midx(midx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s\n", midx->pack_names[preferred_pack]);
|
printf("%s\n", midx->pack_names[preferred_pack]);
|
||||||
|
close_midx(midx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +126,10 @@ static int read_midx_bitmapped_packs(const char *object_dir)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < midx->num_packs + midx->num_packs_in_base; i++) {
|
for (i = 0; i < midx->num_packs + midx->num_packs_in_base; i++) {
|
||||||
if (nth_bitmapped_pack(the_repository, midx, &pack, i) < 0)
|
if (nth_bitmapped_pack(the_repository, midx, &pack, i) < 0) {
|
||||||
|
close_midx(midx);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
printf("%s\n", pack_basename(pack.p));
|
printf("%s\n", pack_basename(pack.p));
|
||||||
printf(" bitmap_pos: %"PRIuMAX"\n", (uintmax_t)pack.bitmap_pos);
|
printf(" bitmap_pos: %"PRIuMAX"\n", (uintmax_t)pack.bitmap_pos);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test_description='multi-pack-indexes'
|
test_description='multi-pack-indexes'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
. "$TEST_DIRECTORY"/lib-chunk.sh
|
. "$TEST_DIRECTORY"/lib-chunk.sh
|
||||||
. "$TEST_DIRECTORY"/lib-midx.sh
|
. "$TEST_DIRECTORY"/lib-midx.sh
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
test_description='git repack works correctly'
|
test_description='git repack works correctly'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
objdir=.git/objects
|
objdir=.git/objects
|
||||||
|
Reference in New Issue
Block a user