SDL: log: Allow log messages of any length.

From 888899244c6dff8f209d52c5c379cc9d162f96a2 Mon Sep 17 00:00:00 2001
From: Eddy Jansson <[EMAIL REDACTED]>
Date: Fri, 29 Apr 2022 16:30:30 +0200
Subject: [PATCH] log: Allow log messages of any length.

Log messages are no longer truncated to SDL_MAX_LOG_MESSAGE.
---
 src/SDL_log.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/SDL_log.c b/src/SDL_log.c
index 5b7ad678615..a4c4d505013 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -320,11 +320,12 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list
 
     /* If message truncated, allocate and re-render */
     if (len >= sizeof(stack_buf)) {
-        message = (char *)SDL_malloc(SDL_MAX_LOG_MESSAGE);
+        /* Allocate exactly what we need, including the zero-terminator */
+        message = (char *)SDL_malloc(len + 1);
         if (!message)
             return;
         va_copy(aq, ap);
-        len = SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, aq);
+        len = SDL_vsnprintf(message, len + 1, fmt, aq);
         va_end(aq);
     } else {
         message = stack_buf;