diff options
| author | Bart Schaefer <schaefer@zsh.org> | 2025-05-12 21:29:16 -0700 |
|---|---|---|
| committer | Bart Schaefer <schaefer@zsh.org> | 2025-05-12 21:29:16 -0700 |
| commit | b0fa403a3da0f01cb75eeea701c652b007b5db1b (patch) | |
| tree | 76e399f6bb21f0570945ae44f651b978033bd7ad /Src/params.c | |
| parent | unposted: fix bad pointer found by valgrind (diff) | |
| download | zsh-b0fa403a3da0f01cb75eeea701c652b007b5db1b.tar zsh-b0fa403a3da0f01cb75eeea701c652b007b5db1b.tar.gz zsh-b0fa403a3da0f01cb75eeea701c652b007b5db1b.tar.bz2 zsh-b0fa403a3da0f01cb75eeea701c652b007b5db1b.tar.lz zsh-b0fa403a3da0f01cb75eeea701c652b007b5db1b.tar.xz zsh-b0fa403a3da0f01cb75eeea701c652b007b5db1b.tar.zst zsh-b0fa403a3da0f01cb75eeea701c652b007b5db1b.zip | |
53602: "typeset -nu" always refers to at a call level above the declaration
Diffstat (limited to 'Src/params.c')
| -rw-r--r-- | Src/params.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Src/params.c b/Src/params.c index 1a2bf62d2..fec1b2c02 100644 --- a/Src/params.c +++ b/Src/params.c @@ -5899,9 +5899,8 @@ scanendscope(HashNode hn, UNUSED(int flags)) pm = hidden; if (pm && (pm->node.flags & PM_NAMEREF) && pm->base >= pm->level && pm->base >= locallevel) { + /* Should never get here for a -u reference */ pm->base = locallevel; - if (pm->level < locallevel && (pm->node.flags & PM_UPPER)) - pm->node.flags &= ~PM_UPPER; } } @@ -6307,7 +6306,9 @@ resolve_nameref(Param pm, const Asgment stop) if (pm) { if (!(stop && (stop->flags & (PM_LOCAL)))) { int scope = ((pm->node.flags & PM_NAMEREF) ? - ((pm->node.flags & PM_UPPER) ? -(pm->base) : + ((pm->node.flags & PM_UPPER) ? + /* pm->base == 0 means not set yet */ + -(pm->base ? pm->base : pm->level) : pm->base) : ((Param)hn)->level); hn = (HashNode)upscope((Param)hn, scope); } @@ -6413,14 +6414,14 @@ setscope(Param pm) } else if (!pm->base) { pm->base = basepm->level; if ((pm->node.flags & PM_UPPER) && - (basepm = upscope(basepm, -locallevel))) + (basepm = upscope(basepm, -(pm->level)))) pm->base = basepm->level; } } else if (pm->base < locallevel && refname && (basepm = (Param)getparamnode(realparamtab, refname))) { pm->base = basepm->level; if ((pm->node.flags & PM_UPPER) && - (basepm = upscope(basepm, -locallevel))) + (basepm = upscope(basepm, -(pm->level)))) pm->base = basepm->level; } if (pm->base > pm->level) { |
