Am 28.12.22 um 19:00 schrieb Ævar Arnfjörð Bjarmason: > Fix a memory leak that's been with us ever since c879daa2372 (Make > hash-object more robust against malformed objects, 2011-02-05). With > "HASH_FORMAT_CHECK" (used by "hash-object" and "replace") we'll parse > tags into a throwaway variable on the stack, but weren't freeing the > "item->tag" we might malloc() when doing so. > > Mark the tests that now pass in their entirety as passing under > "SANITIZE=leak", which means we'll test them as part of the > "linux-leaks" CI job. > > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> > --- > object-file.c | 1 + > t/t3800-mktag.sh | 1 + > t/t5302-pack-index.sh | 2 ++ > 3 files changed, 4 insertions(+) > > diff --git a/object-file.c b/object-file.c > index c1b71c28347..36ed6c3122c 100644 > --- a/object-file.c > +++ b/object-file.c > @@ -2331,6 +2331,7 @@ static void check_tag(const void *buf, size_t size) > memset(&t, 0, sizeof(t)); > if (parse_tag_buffer(the_repository, &t, buf, size)) > die(_("corrupt tag")); > + free(t.tag); Better use release_tag_memory() instead to avoid leaking knowledge of tag internals, no? > } > > static int index_mem(struct index_state *istate, > diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh > index e3cf0ffbe59..d3e428ff46e 100755 > --- a/t/t3800-mktag.sh > +++ b/t/t3800-mktag.sh > @@ -4,6 +4,7 @@ > > test_description='git mktag: tag object verify test' > > +TEST_PASSES_SANITIZE_LEAK=true > . ./test-lib.sh > > ########################################################### > diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh > index b0095ab41d3..54b11f81c63 100755 > --- a/t/t5302-pack-index.sh > +++ b/t/t5302-pack-index.sh > @@ -4,6 +4,8 @@ > # > > test_description='pack index with 64-bit offsets and object CRC' > + > +TEST_PASSES_SANITIZE_LEAK=true > . ./test-lib.sh > > test_expect_success 'setup' '