From b054275fb277d34f98746a1ebcfec1d39d3ce13a Mon Sep 17 00:00:00 2001 From: jackpoz Date: Fri, 31 Jan 2014 22:11:49 +0100 Subject: Shared/Logs: Fix crash in Console log output Correctly handle the return value of vsnprintf() which returns -1 if the buffer is too small http://msdn.microsoft.com/en-us/library/1kt27hek.aspx . In this case just truncate the output. This caused a crash on character delete if Logger.entities.player.dump was enabled and set to 3. Fixes #11539 --- src/server/shared/Utilities/Util.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/server/shared/Utilities/Util.cpp') diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 499ad0502b7..ffef61557fc 100644 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -510,6 +510,9 @@ void vutf8printf(FILE* out, const char *str, va_list* ap) wchar_t wtemp_buf[32*1024]; size_t temp_len = vsnprintf(temp_buf, 32*1024, str, *ap); + //vsnprintf returns -1 if the buffer is too small + if (temp_len == size_t(-1)) + temp_len = 32*1024-1; size_t wtemp_len = 32*1024-1; Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len); -- cgit v1.2.3