diff options
Diffstat (limited to 'common/textconsole.cpp')
-rw-r--r-- | common/textconsole.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/common/textconsole.cpp b/common/textconsole.cpp index f2325ac9ad..ffa42e63a0 100644 --- a/common/textconsole.cpp +++ b/common/textconsole.cpp @@ -46,14 +46,14 @@ void setErrorHandler(ErrorHandler handler) { #ifndef DISABLE_TEXT_CONSOLE void warning(const char *s, ...) { - char buf[STRINGBUFLEN]; + Common::String output; va_list va; va_start(va, s); - vsnprintf(buf, STRINGBUFLEN, s, va); + output = Common::String::vformat(s, va); va_end(va); - Common::String output = Common::String::format("WARNING: %s!\n", buf); + output = "WARNING: " + output + "!\n"; if (g_system) g_system->logMessage(LogMessageType::kWarning, output.c_str()); @@ -64,6 +64,9 @@ void warning(const char *s, ...) { #endif void NORETURN_PRE error(const char *s, ...) { + // We don't use String::vformat here, as that require + // using the heap, and that might be impossible at this + // point, e.g. if the error was an "out-of-memory" error. char buf_input[STRINGBUFLEN]; char buf_output[STRINGBUFLEN]; va_list va; |