Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > Fix a memory leak in the parse_date_format() function by providing a > new date_mode_release() companion function. > > By using this in "t/helper/test-date.c" we can mark the > "t0006-date.sh" test as passing when git is compiled with > SANITIZE=leak, and whitelist it to run under > "GIT_TEST_PASSING_SANITIZE_LEAK=true" by adding > "TEST_PASSES_SANITIZE_LEAK=true" to the test itself. > > The other tests that expose this memory leak (i.e. take the > "mode->type == DATE_STRFTIME" branch in parse_date_format()) are > "t6300-for-each-ref.sh" and "t7004-tag.sh". The former is due to an > easily fixed leak in "ref-filter.c", and brings the failures in > "t6300-for-each-ref.sh" down from 51 to 48. > > Fixing the remaining leaks will have to wait until there's a > release_revisions() in "revision.c", as they have to do with leaks via > "struct rev_info". Here are hits from "git grep -e parse_date_format -e date_mode_release": builtin/blame.c:701: parse_date_format(value, &blame_date_mode); builtin/log.c:162: parse_date_format(default_date_mode, &rev->date_mode); date.c:966:void parse_date_format(const char *format, struct date_mode *mode) date.c:996:void date_mode_release(struct date_mode *mode) date.h:53: * date_mode_release() later. date.h:55:void parse_date_format(const char *format, struct date_mode *mode); date.h:59: * parse_date_format() has parsed a "DATE_STRFTIME" format. date.h:61:void date_mode_release(struct date_mode *mode); ref-filter.c:1266: parse_date_format(formatp, &date_mode); ref-filter.c:1279: date_mode_release(&date_mode); revision.c:2478: parse_date_format(optarg, &revs->date_mode); t/helper/test-date.c:40: parse_date_format(format, &mode); t/helper/test-date.c:58: date_mode_release(&mode); Unlike builtin/log.c which uses the date_mode member that is embedded in a rev_info, the one used by format_time() in builtin/blame.c should be releasable without waiting for updating revision.c, right?