From 4facafcf702ec54694451d5bdda4f1faff94718d Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 4 Apr 2022 13:03:39 -0500 Subject: fix memory leak in _lily_assert_msg --- tests/assertions.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/assertions.c') diff --git a/tests/assertions.c b/tests/assertions.c index 6471225..fa7e82d 100644 --- a/tests/assertions.c +++ b/tests/assertions.c @@ -1,4 +1,5 @@ #include +#include #include #include "lily-test.h" @@ -8,7 +9,7 @@ const char *test_LILY_LOCATION() { // if you move this line, you MUST update the expected string! const char *location = LILY_LOCATION; - int diff = strcmp(location, "tests/assertions.c:10"); + int diff = strcmp(location, "tests/assertions.c:11"); if (diff != 0) return "LILY_LOCATION did not resolve correctly!"; @@ -39,10 +40,11 @@ const char *test_assert_msg() else { if (strcmp(_lily_globals.error_msg, "should fail!") != 0) return "false assertion produced incorrect error message!"; - if (strcmp(_lily_globals.error_location, "tests/assertions.c:36")) + if (strcmp(_lily_globals.error_location, "tests/assertions.c:37")) return "false assertion produced incorrect error location!"; } + free(_lily_globals.error_msg); return 0; } @@ -71,6 +73,7 @@ const char *test_assert_true() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } @@ -98,6 +101,7 @@ const char *test_assert_false() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } @@ -130,6 +134,7 @@ const char *test_assert_not_null() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } @@ -162,6 +167,7 @@ const char *test_assert_null() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } @@ -196,6 +202,7 @@ const char *test_assert_ptr_equal() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } @@ -230,6 +237,7 @@ const char *test_assert_ptr_not_equal() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } @@ -262,6 +270,7 @@ const char *test_assert_int_equal() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } @@ -293,5 +302,6 @@ const char *test_assert_int_not_equal() return "false assertion produced incorrect error message!"; } + free(_lily_globals.error_msg); return 0; } -- cgit v1.2.1