From 84183f5bb6bbb852a585117d31c72f095696d036 Mon Sep 17 00:00:00 2001 From: OswaldHurlem Date: Thu, 26 Jul 2018 13:26:50 -0700 Subject: [PATCH] Assert that fmt != NULL before calling vsnprintf (#1969) In the case of Visual Studio 15.6 + Windows SDK 10.0, vsnprintf() with NULL format string appears to corrupt the stack... --- imgui.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index f62fc398..f946865e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1259,6 +1259,7 @@ static const char* ImAtoi(const char* src, TYPE* output) #ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) { + IM_ASSERT(fmt != NULL); va_list args; va_start(args, fmt); int w = vsnprintf(buf, buf_size, fmt, args); @@ -1273,6 +1274,7 @@ int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) { + IM_ASSERT(fmt != NULL); int w = vsnprintf(buf, buf_size, fmt, args); if (buf == NULL) return w;