diff options
| author | Junio C Hamano <gitster@pobox.com> | 2022-07-18 13:31:54 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-07-18 13:31:54 -0700 |
| commit | f63ac61fbf512ac9446a86bfd9c07b33d4c1e558 (patch) | |
| tree | ca5508c1b830de8f3ea1f2225c60b89373166e3d /t/helper/test-regex.c | |
| parent | Merge branch 'ab/leakfix' (diff) | |
| parent | test-tool delta: fix a memory leak (diff) | |
| download | git-f63ac61fbf512ac9446a86bfd9c07b33d4c1e558.tar.gz git-f63ac61fbf512ac9446a86bfd9c07b33d4c1e558.zip | |
Merge branch 'ab/test-tool-leakfix'
Plug various memory leaks in test-tool commands.
* ab/test-tool-leakfix:
test-tool delta: fix a memory leak
test-tool ref-store: fix a memory leak
test-tool bloom: fix memory leaks
test-tool json-writer: fix memory leaks
test-tool regex: call regfree(), fix memory leaks
test-tool urlmatch-normalization: fix a memory leak
test-tool {dump,scrap}-cache-tree: fix memory leaks
test-tool path-utils: fix a memory leak
test-tool test-hash: fix a memory leak
Diffstat (limited to 't/helper/test-regex.c')
| -rw-r--r-- | t/helper/test-regex.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/t/helper/test-regex.c b/t/helper/test-regex.c index d6f28ca8d1..bd871a735b 100644 --- a/t/helper/test-regex.c +++ b/t/helper/test-regex.c @@ -34,6 +34,7 @@ static int test_regex_bug(void) if (m[0].rm_so == 3) /* matches '\n' when it should not */ die("regex bug confirmed: re-build git with NO_REGEX=1"); + regfree(&r); return 0; } @@ -94,18 +95,20 @@ int cmd__regex(int argc, const char **argv) die("failed regcomp() for pattern '%s' (%s)", pat, errbuf); } if (!str) - return 0; + goto cleanup; ret = regexec(&r, str, 1, m, 0); if (ret) { if (silent || ret == REG_NOMATCH) - return ret; + goto cleanup; regerror(ret, &r, errbuf, sizeof(errbuf)); die("failed regexec() for subject '%s' (%s)", str, errbuf); } - return 0; +cleanup: + regfree(&r); + return ret; usage: usage("\ttest-tool regex --bug\n" "\ttest-tool regex [--silent] <pattern>\n" |
