Bug 413599 - "debug build crashes on exit with memory corruption" [p=a@totic.org (Aleks Totic) r=bsmedberg a1.9=schrep]
authorreed@reedloden.com
Wed, 06 Feb 2008 13:53:43 -0800
changeset 11281 bf7ad73a6b8cb161dbda95a25c1914c641d6bef4
parent 11280 7b12cb9c8c2009a3817b689dc6bf0d54dfbc89df
child 11282 c787ecc1ae41acf16718a5508acc5a6de101eea7
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs413599
milestone1.9b4pre
Bug 413599 - "debug build crashes on exit with memory corruption" [p=a@totic.org (Aleks Totic) r=bsmedberg a1.9=schrep]
toolkit/xre/nsWindowsWMain.cpp
--- a/toolkit/xre/nsWindowsWMain.cpp
+++ b/toolkit/xre/nsWindowsWMain.cpp
@@ -47,12 +47,23 @@ int wmain(int argc, WCHAR **argv)
   for (int i = 0; i < argc; ++i) {
     argvConverted[i] = AllocConvertUTF16toUTF8(argv[i]);
     if (!argvConverted[i]) {
       return 127;
     }
   }
   argvConverted[argc] = NULL;
   
+  // need to save argvConverted copy for later deletion.
+  char **deleteUs = new char*[argc+1];
+  if (!deleteUs) {
+    FreeAllocStrings(argc, argvConverted);
+    return 127;
+  }
+  for (int i=0; i<argc; i++)
+    deleteUs[i] = argvConverted[i];
   int result = main(argc, argvConverted);
-  FreeAllocStrings(argc, argvConverted);
+ 
+  delete[] argvConverted;
+  FreeAllocStrings(argc, deleteUs);
+  
   return result;
 }