From: Michael Tremer Date: Wed, 4 Oct 2023 15:34:54 +0000 (+0000) Subject: tests: string: Free string after the replace test X-Git-Tag: 0.9.30~1555 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f4afcc6793a83986cba1770b739ae8d81dd8052;p=pakfire.git tests: string: Free string after the replace test Generally, we do not free stuff in the tests (because we don't care about any leaks), but I wanted to see a clear valgrind result on this one... Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/string.c b/tests/libpakfire/string.c index 38e56479d..bcf8e1357 100644 --- a/tests/libpakfire/string.c +++ b/tests/libpakfire/string.c @@ -148,15 +148,21 @@ FAIL: } static int test_string_replace(const struct test* t) { - const char* result = pakfire_string_replace( + int r = EXIT_FAILURE; + + char* result = pakfire_string_replace( "ABCABCABCABC", "AB", "CC" ); ASSERT_STRING_EQUALS(result, "CCCCCCCCCCCC"); - return EXIT_SUCCESS; + // Success + r = EXIT_SUCCESS; FAIL: - return EXIT_FAILURE; + if (result) + free(result); + + return r; } static int test_string_join(const struct test* t) {