lib:replace: Fix a memleak in test_strdup()
[kseeger/samba-autobuild/.git] / lib / replace / tests / testsuite.c
index 2ece95332d23ec74ef962025187dda01f566deda..6d87b8ed61160fc3bb742901fb9e8133fc80b78b 100644 (file)
@@ -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);