Bug 1449254 - Use vsnprintf for formatting DebugDump() output on Windows, too. r?mrbkap draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Tue, 27 Mar 2018 19:26:04 +0200
changeset 773285 c97baeddc1b352ef667e291f6bd1a6f1ca45d15f
parent 773241 ddd7beef248b82acdf9505a4daed8dfb2687abb1
push id104206
push usermozilla@buttercookie.de
push dateTue, 27 Mar 2018 20:03:40 +0000
reviewersmrbkap
bugs1449254
milestone61.0a1
Bug 1449254 - Use vsnprintf for formatting DebugDump() output on Windows, too. r?mrbkap Since VS2015, vsnprintf is supposed to be C99-compliant on Windows, too and will especially always null-terminate the string written into the given buffer. In addition, the build define we were using was misspelled and therefore not working anyway, so might we as well remove it now. MozReview-Commit-ID: 44ERI6TUz1B
js/xpconnect/src/XPCDebug.cpp
--- a/js/xpconnect/src/XPCDebug.cpp
+++ b/js/xpconnect/src/XPCDebug.cpp
@@ -18,22 +18,17 @@
 #include <windows.h>
 #endif
 
 static void DebugDump(const char* fmt, ...)
 {
   char buffer[2048];
   va_list ap;
   va_start(ap, fmt);
-#ifdef XPWIN
-  _vsnprintf(buffer, sizeof(buffer), fmt, ap);
-  buffer[sizeof(buffer)-1] = '\0';
-#else
   VsprintfLiteral(buffer, fmt, ap);
-#endif
   va_end(ap);
 #ifdef ANDROID
   __android_log_write(ANDROID_LOG_DEBUG, "Gecko", buffer);
 #elif XP_WIN
   if (IsDebuggerPresent()) {
     OutputDebugStringA(buffer);
   }
 #endif