From 8a8080292318a2141b0c2fe5896fb1cab1d9b0dc Mon Sep 17 00:00:00 2001 From: DissolveDZ Date: Sun, 1 Oct 2023 00:20:21 +0200 Subject: [PATCH] resolved some warnings --- src/rtext.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index 2a736e62f..d83c62ba7 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1367,17 +1367,16 @@ const char *TextFormat(const char *text, ...) va_list args; va_start(args, text); - int length = vsnprintf(NULL, 0, text, args); // Determine the length of the formatted string - if (length < 0) + int length = vsnprintf(NULL, 0, text, args); + + if (length < 0 || length >= MAX_TEXT_BUFFER_LENGTH) { - // Handle error va_end(args); return NULL; } - va_end(args); // Reset the va_list - - va_start(args, text); // Start again for the actual formatting + va_end(args); + va_start(args, text); vsnprintf(formatBuffer, length + 1, text, args); // Format the string and copy it to the result buffer va_end(args);