diff options
author | sanine <sanine.not@pm.me> | 2022-04-04 13:03:39 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-04-04 13:03:39 -0500 |
commit | 4facafcf702ec54694451d5bdda4f1faff94718d (patch) | |
tree | 90f869e21579cda0f8e0848b2744971ce913dace /lily-test.c | |
parent | c4619e22d571bffa75ab033fceda7915c676f90d (diff) |
fix memory leak in _lily_assert_msg
Diffstat (limited to 'lily-test.c')
-rw-r--r-- | lily-test.c | 6 |
1 files changed, 2 insertions, 4 deletions
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); |