From 943dd8e0d11147bf7c7e5121f57e072b2bb41591 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Sun, 22 Nov 2020 01:44:08 +0100 Subject: [PATCH] Make logger buffer bigger --- src/logger.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/logger.c b/src/logger.c index 2561462..290c5b3 100644 --- a/src/logger.c +++ b/src/logger.c @@ -65,7 +65,13 @@ logger_log(int level, const char *filename, int line, const char *func, const ch strftime(timestamp_str, 32, "%Y-%m-%d %H:%M:%S", localtime(&rawtime)); size_t timestamp_len = strlen(timestamp_str); - char *buffer = malloc(sizeof(char) * (128 + strlen(msg) + timestamp_len)); + size_t buffer_size = 128; + buffer_size += timestamp_len; + buffer_size += strlen(filename); + buffer_size += strlen(func); + buffer_size += strlen(msg); + + char *buffer = malloc(sizeof(char) * (buffer_size); sprintf(buffer, "%s %s[%5s] %s:%d:%s " COLOR_NONE "%s", timestamp_str, color, level_str, filename, line, func, msg); // start arg va_list and find log_len