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>
This commit is contained in:

committed by
Junio C Hamano

parent
9afa46d4a6
commit
1c343e5aef
@ -5,8 +5,9 @@
|
|||||||
int cmd__urlmatch_normalization(int argc, const char **argv)
|
int cmd__urlmatch_normalization(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
const char usage[] = "test-tool urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";
|
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 opt_p = 0, opt_l = 0;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For one url, succeed if url_normalize succeeds on it, fail otherwise.
|
* 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);
|
printf("%s\n", url1);
|
||||||
if (opt_l)
|
if (opt_l)
|
||||||
printf("%u\n", (unsigned)info.url_len);
|
printf("%u\n", (unsigned)info.url_len);
|
||||||
return 0;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_p || opt_l)
|
if (opt_p || opt_l)
|
||||||
@ -47,5 +48,9 @@ int cmd__urlmatch_normalization(int argc, const char **argv)
|
|||||||
|
|
||||||
url1 = url_normalize(argv[1], NULL);
|
url1 = url_normalize(argv[1], NULL);
|
||||||
url2 = url_normalize(argv[2], 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;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test_description='urlmatch URL normalization'
|
test_description='urlmatch URL normalization'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
# The base name of the test url files
|
# The base name of the test url files
|
||||||
|
Reference in New Issue
Block a user