Backing out bug 492225 on suspicion of causing Windows leak test fatal assertion.
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 18 May 2009 11:20:44 +1200
changeset 28479 a7c0b35882423074a5a1150d8d8f670ac911898e
parent 28478 773dc0ba39c33ad2701f40dd1fb23d3f4072f3b9
child 28480 4c6d522e3075eada7a524a2ab1f23958e2b95def
push id7078
push userrocallahan@mozilla.com
push dateSun, 17 May 2009 23:21:31 +0000
treeherdermozilla-central@a7c0b3588242 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs492225
milestone1.9.2a1pre
Backing out bug 492225 on suspicion of causing Windows leak test fatal assertion.
toolkit/xre/nsWindowsWMain.cpp
--- a/toolkit/xre/nsWindowsWMain.cpp
+++ b/toolkit/xre/nsWindowsWMain.cpp
@@ -1,16 +1,18 @@
 // This file is a .cpp file meant to be included in nsBrowserApp.cpp and other
 // similar bootstrap code. It converts wide-character windows wmain into UTF-8
 // narrow-character strings.
 
 #ifndef XP_WIN
 #error This file only makes sense on Windows.
 #endif
 
+#include "nsUTF8Utils.h"
+
 #ifdef __MINGW32__
 
 /* MingW currently does not implement a wide version of the
    startup routines.  Workaround is to implement something like
    it ourselves.  See bug 411826 */
 
 #include <shellapi.h>
 
@@ -25,31 +27,32 @@ int main(int argc, char **argv)
     return 127;
 
   int result = wmain(argcw, argvw);
   LocalFree(argvw);
   return result;
 }
 #endif /* __MINGW32__ */
 
-#include <windows.h>
 #define main NS_internal_main
 
 int main(int argc, char **argv);
 
 static char*
 AllocConvertUTF16toUTF8(const WCHAR *arg)
 {
   // be generous... UTF16 units can expand up to 3 UTF8 units
   int len = wcslen(arg);
   char *s = new char[len * 3 + 1];
   if (!s)
     return NULL;
 
-  WideCharToMultiByte(CP_UTF8, 0, arg, len, s, len * 3 + 1, 0, 0);
+  ConvertUTF16toUTF8 convert(s);
+  convert.write(arg, len);
+  convert.write_terminator();
   return s;
 }
 
 static void
 FreeAllocStrings(int argc, char **argv)
 {
   while (argc) {
     --argc;