From 6a38b0247cff3be5ce2d0f725d559253357b4dc6 Mon Sep 17 00:00:00 2001 From: A404M Date: Sun, 9 Feb 2025 04:33:05 +0330 Subject: fix leaks fix printError --- src/utils/log.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/utils/log.c') diff --git a/src/utils/log.c b/src/utils/log.c index e1822c0..3f73729 100644 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -17,8 +17,8 @@ void _printLogBack(const char *format, const char *file, int line, ...) { free(errorStr); } -void _printErrorBack(const char *format, const char *file, int line, - char *begin, char *end, ...) { +void _printErrorBack(const char *file, int line, char *begin, char *end, + const char *format, ...) { va_list args; va_start(args, end); char *errorStr; @@ -51,7 +51,8 @@ void _printErrorBack(const char *format, const char *file, int line, if (*iter == '\n') { if (iter <= begin) { file_line_begin = iter + 1; - } else if (iter >= end) { + } + if (iter >= end && file_line_end == fileCodes[file_index]) { file_line_end = iter; } if (iter <= end) { @@ -71,5 +72,5 @@ void _printErrorBack(const char *format, const char *file, int line, } fprintf(stderr, "%c", *iter); } - fprintf(stderr, "\e[0m"); + fprintf(stderr, "\e[0m\n"); } -- cgit v1.2.3