diff options
| author | Philippe Altherr <philippe.altherr@gmail.com> | 2025-10-26 17:11:32 -0700 |
|---|---|---|
| committer | Bart Schaefer <schaefer@zsh.org> | 2025-10-26 17:11:32 -0700 |
| commit | 7546c18076fc16c7f2326b54d7efb10f5854c461 (patch) | |
| tree | 5f9ba389e3f462a3380e95c8aa0eb3a2be9da67a | |
| parent | 53796: fix local reference chains and detect self-reference across local scopes (diff) | |
| download | zsh-7546c18076fc16c7f2326b54d7efb10f5854c461.tar zsh-7546c18076fc16c7f2326b54d7efb10f5854c461.tar.gz zsh-7546c18076fc16c7f2326b54d7efb10f5854c461.tar.bz2 zsh-7546c18076fc16c7f2326b54d7efb10f5854c461.tar.lz zsh-7546c18076fc16c7f2326b54d7efb10f5854c461.tar.xz zsh-7546c18076fc16c7f2326b54d7efb10f5854c461.tar.zst zsh-7546c18076fc16c7f2326b54d7efb10f5854c461.zip | |
53797: fix creation of undeclared target variable through reference chain
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | Src/params.c | 2 | ||||
| -rw-r--r-- | Test/K01nameref.ztst | 14 |
3 files changed, 18 insertions, 1 deletions
@@ -14,6 +14,9 @@ * Philippe: 53796: Src/params.c, Test/K01nameref.ztst: fix local reference chains and detect self-reference across local scopes + * Philippe: 53797: Src/params.c, Test/K01nameref.ztst: fix creation + of undeclared target variable through reference chain + 2025-10-24 Oliver Kiddle <opk@zsh.org> * 54002: Src/parse.c: silence compiler warning for static function diff --git a/Src/params.c b/Src/params.c index 361f173ce..cf6abcf48 100644 --- a/Src/params.c +++ b/Src/params.c @@ -1048,7 +1048,7 @@ createparam(char *name, int flags) (oldpm = upscope(oldpm, oldpm->base))) { Param lastpm; struct asgment stop; - stop.flags = PM_NAMEREF | (flags & PM_LOCAL); + stop.flags = PM_NAMEREF; stop.name = oldpm->node.nam; stop.value.scalar = GETREFNAME(oldpm); lastpm = (Param)resolve_nameref(oldpm, &stop); diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst index 49a9a9d4d..1a41c4756 100644 --- a/Test/K01nameref.ztst +++ b/Test/K01nameref.ztst @@ -1179,6 +1179,20 @@ F:previously this could create an infinite recursion and crash >typeset PS1=zz *?* + unset var1 var2 + typeset -n ref1=var1 + () { + typeset -n ref2=ref1 + typeset -n ref1=var2 + typeset -i ref2=42 + typeset -p ref1 ref2 var1 var2 + } +1:typeset reference chain to not-yet-defined variable including a hidden reference +?(anon):typeset:4: no such variable: var2 +>typeset -n ref1=var2 +>typeset -n ref2=ref1 +>typeset -i var1=42 + typeset -n ref1 typeset -n ref2=ref1 () { |
