aboutsummaryrefslogtreecommitdiffstats
path: root/t/helper/test-urlmatch-normalization.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-07-01 12:37:35 +0200
committerJunio C Hamano <gitster@pobox.com>2022-07-01 13:38:49 -0700
commit1c343e5aef0599a7a4816aa7fce5c7c84c10388d (patch)
tree6d6c0c5deda0004b607aff2a015c03e01e8be083 /t/helper/test-urlmatch-normalization.c
parenttest-tool {dump,scrap}-cache-tree: fix memory leaks (diff)
downloadgit-1c343e5aef0599a7a4816aa7fce5c7c84c10388d.tar.gz
git-1c343e5aef0599a7a4816aa7fce5c7c84c10388d.zip
test-tool urlmatch-normalization: fix a memory leak
Fix a memory leak in "test-tool urlmatch-normalization", as a result we can mark the corresponding test as passing with SANITIZE=leak using "TEST_PASSES_SANITIZE_LEAK=true". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper/test-urlmatch-normalization.c')
-rw-r--r--t/helper/test-urlmatch-normalization.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/t/helper/test-urlmatch-normalization.c b/t/helper/test-urlmatch-normalization.c
index 8f4d67e646..86edd454f5 100644
--- a/t/helper/test-urlmatch-normalization.c
+++ b/t/helper/test-urlmatch-normalization.c
@@ -5,8 +5,9 @@
int cmd__urlmatch_normalization(int argc, const char **argv)
{
const char usage[] = "test-tool urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";
- char *url1, *url2;
+ char *url1 = NULL, *url2 = NULL;
int opt_p = 0, opt_l = 0;
+ int ret = 0;
/*
* For one url, succeed if url_normalize succeeds on it, fail otherwise.
@@ -39,7 +40,7 @@ int cmd__urlmatch_normalization(int argc, const char **argv)
printf("%s\n", url1);
if (opt_l)
printf("%u\n", (unsigned)info.url_len);
- return 0;
+ goto cleanup;
}
if (opt_p || opt_l)
@@ -47,5 +48,9 @@ int cmd__urlmatch_normalization(int argc, const char **argv)
url1 = url_normalize(argv[1], NULL);
url2 = url_normalize(argv[2], NULL);
- return (url1 && url2 && !strcmp(url1, url2)) ? 0 : 1;
+ ret = (url1 && url2 && !strcmp(url1, url2)) ? 0 : 1;
+cleanup:
+ free(url1);
+ free(url2);
+ return ret;
}