From: Andreas Schneider Date: Thu, 22 Apr 2021 13:03:25 +0000 (+0200) Subject: lib:replace: Fix a memleak in test_strdup() X-Git-Tag: tevent-0.11.0~1040 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dca03ffa8ab682a2705da8cb25cab899338a1375;p=thirdparty%2Fsamba.git lib:replace: Fix a memleak in test_strdup() Found by covscan Signed-off-by: Andreas Schneider Reviewed-by: Jeremy Allison --- diff --git a/lib/replace/tests/testsuite.c b/lib/replace/tests/testsuite.c index 2ece95332d2..6d87b8ed611 100644 --- a/lib/replace/tests/testsuite.c +++ b/lib/replace/tests/testsuite.c @@ -164,11 +164,16 @@ static int test_memmove(void) static int test_strdup(void) { char *x; + int cmp; + printf("test: strdup\n"); x = strdup("bla"); - if (strcmp("bla", x) != 0) { + + cmp = strcmp("bla", x); + if (cmp != 0) { printf("failure: strdup [\nfailed: expected \"bla\", got \"%s\"\n]\n", x); + free(x); return false; } free(x);