Skip to content

Commit fed3e8b

Browse files
committed
Fix errors with debug logging
Variadic arguments cannot be passed to variadic functions, only to ones explicitly taking va_list as argument. Phobos does it like this using a separate buffer to prevent potential issues with overwriting with the main string write buffer.
1 parent 3f5038a commit fed3e8b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Utilities/Debug.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
#include <Utilities/Macro.h>
2727

2828
char Debug::StringBuffer[0x1000];
29+
char Debug::FinalStringBuffer[0x1000];
2930

3031
void Debug::Log(const char* pFormat, ...)
3132
{
3233
va_list args;
33-
Debug::LogGame("[Spawner] ");
34-
Debug::LogGame(pFormat, args);
34+
va_start(args, pFormat);
35+
vsprintf_s(FinalStringBuffer, pFormat, args);
36+
LogGame("%s %s", "[Phobos]", FinalStringBuffer);
3537
va_end(args);
3638
}
3739

src/Utilities/Debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Debug
3030
};
3131

3232
static char StringBuffer[0x1000];
33+
static char FinalStringBuffer[0x1000];
3334

3435
static void Log(const char* pFormat, ...);
3536
static void LogGame(const char* pFormat, ...);

0 commit comments

Comments
 (0)