diff options
author | Bart Schaefer <schaefer@zsh.org> | 2024-08-05 15:59:48 -0700 |
---|---|---|
committer | Bart Schaefer <schaefer@zsh.org> | 2024-08-05 15:59:48 -0700 |
commit | 72751bfe1f9e37145c12e244ebb1729c27aff901 (patch) | |
tree | d62de34dce50366129876cdac338682662b68cc6 /Src | |
parent | 65da4674410abac23e41f89f29f6613d74858854 (diff) | |
download | zsh-72751bfe1f9e37145c12e244ebb1729c27aff901.tar.gz zsh-72751bfe1f9e37145c12e244ebb1729c27aff901.tar.xz zsh-72751bfe1f9e37145c12e244ebb1729c27aff901.zip |
53025: fix memory leaks and pointer errors upon named reference self-reference
Diffstat (limited to 'Src')
-rw-r--r-- | Src/loop.c | 2 | ||||
-rw-r--r-- | Src/params.c | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Src/loop.c b/Src/loop.c index 0f3847541..84dc66476 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -165,7 +165,7 @@ execfor(Estate state, int do_exec) fprintf(xtrerr, "%s=%s\n", name, str); fflush(xtrerr); } - setloopvar(name, ztrdup(str)); + setloopvar(name, str); count++; } if (!count) diff --git a/Src/params.c b/Src/params.c index 83bdb785d..f143a790f 100644 --- a/Src/params.c +++ b/Src/params.c @@ -2811,9 +2811,10 @@ assignstrvalue(Value v, char *val, int flags) break; } setscope(v->pm); - if ((!v->pm->env && !(v->pm->node.flags & PM_EXPORTED) && - !(isset(ALLEXPORT) && !(v->pm->node.flags & PM_HASHELEM))) || - (v->pm->node.flags & PM_ARRAY) || v->pm->ename) + if (errflag || + ((!v->pm->env && !(v->pm->node.flags & PM_EXPORTED) && + !(isset(ALLEXPORT) && !(v->pm->node.flags & PM_HASHELEM))) || + (v->pm->node.flags & PM_ARRAY) || v->pm->ename)) return; export_param(v->pm); } @@ -6330,9 +6331,10 @@ setloopvar(char *name, char *value) pm->node.flags &= ~PM_UNSET; pm->node.flags |= PM_NEWREF; setscope(pm); - pm->node.flags &= ~PM_NEWREF; + if (!errflag) + pm->node.flags &= ~PM_NEWREF; } else - setsparam(name, value); + setsparam(name, ztrdup(value)); } /**/ |