foxygit / doom Log in
commit 745e7342badc686f40ee25c2fa211e69924ad938
Author:     Turo Lamminen <turol@iki.fi>
AuthorDate: Mon Feb 1 15:39:23 2021 +0200
Commit:     Turo Lamminen <turol@iki.fi>
CommitDate: Tue Aug 24 18:11:02 2021 +0300

    Free any old strings in myargv which were not moved to newargv
---
 src/m_argv.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/m_argv.c b/src/m_argv.c
index 010f2e74..8afd1412 100644
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -214,6 +214,16 @@ static void LoadResponseFile(int argv_index, const char *filename)
         ++newargc;
     }

+    // Free any old strings in myargv which were not moved to newargv
+    for (i = 0; i < myargc; ++i)
+    {
+        if (myargv[i] != NULL)
+        {
+            free(myargv[i]);
+            myargv[i] = NULL;
+        }
+    }
+
     free(myargv);
     myargv = newargv;
     myargc = newargc;