summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2018-04-17 02:55:16 +0200
committerAxel Beckert <abe@deuxchevaux.org>2018-04-17 02:55:16 +0200
commit03fcdd08a35697ef0f01673c243420e3d13b47e0 (patch)
treeef1230281d685eae583c8ecbb36af72506ad4a1e /Src/exec.c
parentf0421610cd92ad949eedb22390a908020a1d0e1e (diff)
parentfd4056f4edb12000ac5b0181aef8bb741e60801c (diff)
downloadzsh-03fcdd08a35697ef0f01673c243420e3d13b47e0.tar.gz
zsh-03fcdd08a35697ef0f01673c243420e3d13b47e0.zip
Merge tag 'zsh-5.5.1' and branch 'upstream' into branch 'debian'
Release 5.5.1.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Src/exec.c b/Src/exec.c
index e154d1249..216057aa7 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5042,7 +5042,7 @@ execfuncdef(Estate state, Eprog redir_prog)
Shfunc shf;
char *s = NULL;
int signum, nprg, sbeg, nstrs, npats, len, plen, i, htok = 0, ret = 0;
- int nfunc = 0, anon_func = 0;
+ int anon_func = 0;
Wordcode beg = state->pc, end;
Eprog prog;
Patprog *pp;
@@ -5118,12 +5118,16 @@ execfuncdef(Estate state, Eprog redir_prog)
/*
* redir_prog is permanently allocated --- but if
* this function has multiple names we need an additional
- * one.
+ * one. Original redir_prog used with the last name
+ * because earlier functions are freed in case of duplicate
+ * names.
*/
- if (nfunc++ && redir_prog)
+ if (names && nonempty(names) && redir_prog)
shf->redir = dupeprog(redir_prog, 0);
- else
+ else {
shf->redir = redir_prog;
+ redir_prog = 0;
+ }
shfunc_set_sticky(shf);
if (!names) {
@@ -5203,7 +5207,7 @@ execfuncdef(Estate state, Eprog redir_prog)
}
if (!anon_func)
setunderscore("");
- if (!nfunc && redir_prog) {
+ if (redir_prog) {
/* For completeness, shouldn't happen */
freeeprog(redir_prog);
}