bug 473151 - limit the number of characters usable in windbgdlg; r=timeless sr=neil
authorMook <mook.moz+hg@gmail.com>
Thu, 19 Feb 2009 18:23:15 +0100
changeset 25223 d1992b74f2c0380a606475f6e886f364ba6f2a96
parent 25222 9db614caf1da75c16d0454ca339f6bf61786f13b
child 25224 356065cfe21b47d494c642db442be957f3f94eb3
push id5457
push usersgautherie.bz@free.fr
push dateThu, 19 Feb 2009 17:24:13 +0000
treeherdermozilla-central@f796debb11af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimeless, neil
bugs473151
milestone1.9.2a1pre
bug 473151 - limit the number of characters usable in windbgdlg; r=timeless sr=neil
xpcom/windbgdlg/windbgdlg.cpp
--- a/xpcom/windbgdlg/windbgdlg.cpp
+++ b/xpcom/windbgdlg/windbgdlg.cpp
@@ -34,28 +34,27 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* Windows only app to show a modal debug dialog - launched by nsDebug.cpp */
-
 #include <windows.h>
 #include <stdlib.h>
-
+#ifdef _MSC_VER
+#include <strsafe.h>
+#endif
 #ifdef __MINGW32__
-
 /* MingW currently does not implement a wide version of the
    startup routines.  Workaround is to implement something like
    it ourselves.  See bug 472063 */
-
+#include <stdio.h>
 #include <shellapi.h>
-
 int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
 
 #undef __argc
 #undef __wargv
 
 static int __argc;
 static wchar_t** __wargv;
 
@@ -131,20 +130,26 @@ wWinMain(HINSTANCE  hInstance, HINSTANCE
             regValue = -1;
     }
     if (hkeyCU)
         RegCloseKey(hkeyCU);
     if (hkeyLM)
         RegCloseKey(hkeyLM);
     if (regValue != (DWORD)-1 && regValue != (DWORD)-2)
         return regValue;
-    static WCHAR msg[4048];
+    static const int size = 4096;
+    static WCHAR msg[size];
 
-    wsprintfW(msg,
+#ifdef _MSC_VER
+    StringCchPrintfW(msg,
+#else
+    snwprintf(msg,
+#endif
+              size,
               L"%s\n\nClick Abort to exit the Application.\n"
               L"Click Retry to Debug the Application.\n"
               L"Click Ignore to continue running the Application.",
               lpszCmdLine);
-
+    msg[size - 1] = L'\0';
     return MessageBoxW(NULL, msg, L"NSGlue_Assertion",
                        MB_ICONSTOP | MB_SYSTEMMODAL |
                        MB_ABORTRETRYIGNORE | MB_DEFBUTTON3);
 }