summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/init.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index cb3b5e78d..36c73eb5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
 	* 35477: Completion/Unix/Command/_gdb: _gdb: Allow 'core' to
 	occur anywhere in a coredump filename
 
+2015-06-16  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 35482: Src/init.c: be consistent about how argzero is allocated
+
 2015-06-14  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 35469: Functions/Zle/smart-insert-last-word: test UNDO_CHANGE_NO
diff --git a/Src/init.c b/Src/init.c
index 102276a64..0fe4d758c 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1117,8 +1117,9 @@ setupshin(char *runscript)
 	    exit(127);
 	}
 	scriptfilename = sfname;
-	zsfree(argzero); /* ztrdup'd in parseargs */
-	argzero = runscript;
+	sfname = argzero; /* copy to avoid race condition */
+	argzero = ztrdup(runscript);
+	zsfree(sfname); /* argzero ztrdup'd in parseargs */
     }
     /*
      * We only initialise line numbering once there is a script to