diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 9ca832b9c7a6c7b21ab9309f49793eb485ae97f9..f41f88fd34a7427fa205e45de105b9c018b0c362 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -398,8 +398,11 @@ void HU_AddChatText(const char *text, boolean playsound) if (OLDCHAT) // if we're using oldchat, print directly in console CONS_Printf("%s\n", text); - else // if we aren't, still save the message to log.txt - CON_LogMessage(va("%s\n", text)); + else // if we aren't, still save the message to log.txt + { + CON_LogMessage(text); + CON_LogMessage("\n"); // Add newline. Don't use va for that, since `text` might be refering to va's buffer itself + } } /** Runs a say command, sending an ::XD_SAY message. diff --git a/src/m_misc.c b/src/m_misc.c index fe3d2dacf31e5fe35d756cb0df8ed19ff8851c6e..fc4b2a12df7b04cca7b15127ee4f48c2e87af69e 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1720,7 +1720,7 @@ char *va(const char *format, ...) static char string[1024]; va_start(argptr, format); - vsprintf(string, format, argptr); + vsnprintf(string, 1024, format, argptr); va_end(argptr); return string;