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 --- lily-test.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lily-test.c') diff --git a/lily-test.c b/lily-test.c index 7484894..17959ca 100644 --- a/lily-test.c +++ b/lily-test.c @@ -30,7 +30,8 @@ static void _lily_assert_msg(bool statement, const char *location, size_t length = vsnprintf(NULL, 0, format_string, args_len); va_end(args_len); - if (_lily_globals.error_msg_len < length+1) { + if (_lily_globals.error_msg_len < length+1 || + _lily_globals.error_msg == NULL) { if (_lily_globals.error_msg != NULL) free(_lily_globals.error_msg); @@ -46,12 +47,9 @@ static void _lily_assert_msg(bool statement, const char *location, else { _lily_globals.error_msg = msg; _lily_globals.error_msg_len = length+1; - printf("reallocated global msg: %p ", msg); } } - printf("length: %lu ", length); - vsnprintf(_lily_globals.error_msg, length+1, format_string, args); va_end(args); -- cgit v1.2.1