diff options
author | Marc Gilleron <marc.gilleron@gmail.com> | 2016-09-29 03:15:12 +0200 |
---|---|---|
committer | Marc Gilleron <marc.gilleron@gmail.com> | 2016-09-29 03:15:12 +0200 |
commit | 0c09de3ef175b52937ffa2bba89a328cb282ad65 (patch) | |
tree | bbd8c0805cf5b819f67947841d8fd27a3fdb9d49 /platform | |
parent | 68325d7254db711beaedddad218e2cddb405c42c (diff) |
Windows: prevent huge prints from crashing the engine
Diffstat (limited to 'platform')
-rw-r--r-- | platform/windows/os_windows.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index cebafdabce..f38bda5899 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1312,10 +1312,13 @@ void OS_Windows::finalize_core() { void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) { - char buf[16384+1]; - int len = vsnprintf(buf,16384,p_format,p_list); + const unsigned int BUFFER_SIZE = 16384; + char buf[BUFFER_SIZE+1]; // +1 for the terminating character + int len = vsnprintf(buf,BUFFER_SIZE,p_format,p_list); if (len<=0) return; + if(len >= BUFFER_SIZE) + len = BUFFER_SIZE; // Output is too big, will be truncated buf[len]=0; |