]> git.lyx.org Git - lyx.git/blobdiff - src/support/os_win32.cpp
Fix bug 9798.
[lyx.git] / src / support / os_win32.cpp
index a5b5bbe825cbe79c1da55fc3a8110de7bb851199..8d521383f205e3dec828f379a5c1cb40bce0a68f 100644 (file)
@@ -97,9 +97,9 @@ BOOL terminate_handler(DWORD event)
        return FALSE;
 }
 
-} // namespace anon
+} // namespace
 
-void init(int argc, char * argv[])
+void init(int argc, char ** argv[])
 {
        /* Note from Angus, 17 Jan 2005:
         *
@@ -158,6 +158,22 @@ void init(int argc, char * argv[])
         */
 
 
+#if defined(_MSC_VER) && (_MSC_VER >= 1900)
+       // Removing an argument from argv leads to an assertion on Windows
+       // when compiling with MSVC 2015 in debug mode (see bug #10440).
+       // To avoid this we make a copy of the array of pointers.
+       char ** newargv = (char **) malloc((argc + 1) * sizeof(char *));
+       if (newargv) {
+               memcpy(newargv, *argv, (argc + 1) * sizeof(char *));
+               *argv = newargv;
+       } else {
+               lyxerr << "LyX warning: Cannot make a copy of "
+                         "command line arguments!"
+                      << endl;
+       }
+#endif
+
+
        // Get the wide program arguments array
 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
        argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_);