shithub: choc

Download patch

ref: 7646d7372e4d21893f75e1111d86a39a842d9a81
parent: a0d84d648f139c2937cc49808f8cca8337315086
author: Turo Lamminen <turol@iki.fi>
date: Mon Feb 1 10:34:00 EST 2021

Store new strings in argv instead of direct pointers to response file buffer

--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -159,10 +159,11 @@
 
         if (infile[k] == '\"')
         {
+            char *argstart;
             // Skip the first character(")
             ++k;
 
-            newargv[newargc++] = &infile[k];
+            argstart = &infile[k];
 
             // Read all characters between quotes
 
@@ -181,12 +182,14 @@
 
             infile[k] = '\0';
             ++k;
+            newargv[newargc++] = M_StringDuplicate(argstart);
         }
         else
         {
+            char *argstart;
             // Read in the next argument until a space is reached
 
-            newargv[newargc++] = &infile[k];
+            argstart = &infile[k];
 
             while(k < size && !isspace(infile[k]))
             {
@@ -198,6 +201,7 @@
             infile[k] = '\0';
 
             ++k;
+            newargv[newargc++] = M_StringDuplicate(argstart);
         }
     }