about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2019-07-15 09:44:47 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2019-07-15 09:44:47 +0100
commit8cbbc04d97d1126d17060353a8cf85de44cb3053 (patch)
tree7bc61052257f73e77dab8905fab8a53b4d7d1554 /Src
parent09385d38ad51477dcc3a20ace67ec50de5fb262e (diff)
downloadzsh-8cbbc04d97d1126d17060353a8cf85de44cb3053.tar.gz
zsh-8cbbc04d97d1126d17060353a8cf85de44cb3053.tar.xz
zsh-8cbbc04d97d1126d17060353a8cf85de44cb3053.zip
44509: Prevent crash with modified path / PATH combination.
Crash came from "fn() { typeset -U path=($path); unset PATH; }".

Note PATH unset is global as only path was made local.
Diffstat (limited to 'Src')
-rw-r--r--Src/params.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Src/params.c b/Src/params.c
index 1859c7c12..1499e3a40 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3617,10 +3617,18 @@ unsetparam_pm(Param pm, int altflag, int exp)
 	altpm = (Param) paramtab->getnode(paramtab, altremove);
 	/* tied parameters are at the same local level as each other */
 	oldpm = NULL;
-	while (altpm && altpm->level > pm->level) {
-	    /* param under alternate name hidden by a local */
-	    oldpm = altpm;
-	    altpm = altpm->old;
+	/*
+	 * Look for param under alternate name hidden by a local.
+	 * If this parameter is special, however, the visible
+	 * parameter is the special and the hidden one is keeping
+	 * an old value --- we just mark the visible one as unset.
+	 */
+	if (altpm && !(altpm->node.flags & PM_SPECIAL))
+	{
+	    while (altpm && altpm->level > pm->level) {
+		oldpm = altpm;
+		altpm = altpm->old;
+	    }
 	}
 	if (altpm) {
 	    if (oldpm && !altpm->level) {