summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/utils.c7
2 files changed, 7 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 4ab9b14ed..8c8791cf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@
 
 2016-01-25  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 37780: Kamil Dudka: Src/utils.c: Careful in case both argzero
+	and scriptname are null in zerr().
+
 	* 37765: Src/builtin.c, Test/C04funcdef.ztst: Use FS_FUNC on
 	funcstack to find autoload -X target rather than scriptname.
 
diff --git a/Src/utils.c b/Src/utils.c
index 17ebfebf9..053731cfa 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -133,9 +133,11 @@ zwarning(const char *cmd, const char *fmt, va_list ap)
     if (isatty(2))
 	zleentry(ZLE_CMD_TRASH);
 
+    char *prefix = scriptname ? scriptname : (argzero ? argzero : "");
+
     if (cmd) {
 	if (unset(SHINSTDIN) || locallevel) {
-	    nicezputs(scriptname ? scriptname : argzero, stderr);
+	    nicezputs(prefix, stderr);
 	    fputc((unsigned char)':', stderr);
 	}
 	nicezputs(cmd, stderr);
@@ -147,8 +149,7 @@ zwarning(const char *cmd, const char *fmt, va_list ap)
 	 * program/script is running.  It's also set in shell functions,
 	 * so test locallevel, too.
 	 */
-	nicezputs((isset(SHINSTDIN) && !locallevel) ? "zsh" :
-		  scriptname ? scriptname : argzero, stderr);
+	nicezputs((isset(SHINSTDIN) && !locallevel) ? "zsh" : prefix, stderr);
 	fputc((unsigned char)':', stderr);
     }