mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-05-20 06:56:05 +02:00
unposted: more care with shell function filename.
When updating shfunc structure to change filename we should be careful to free whatever's there already, we may now be the directory in which to find the function definition. After loading the field contains the full name of the file.
This commit is contained in:
parent
f26d1ba6b0
commit
47b7f2adef
|
@ -1,5 +1,8 @@
|
|||
2017-01-11 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* unposted: Src/builtin.c, Src/exec.c: be more careful to free
|
||||
memory when updating filename in struct shfunc.
|
||||
|
||||
* 40327 (with minor fixes): Doc/Zsh/builtins.yo,
|
||||
README,Src/builtin.c, Src/exec.c, Src/hashtable.c, Src/parse.c,
|
||||
Src/zsh.h, Test/C04funcdef.ztst: add ability to autoload
|
||||
|
|
|
@ -3275,8 +3275,10 @@ bin_functions(char *name, char **argv, Options ops, int func)
|
|||
shf = (Shfunc) zshcalloc(sizeof *shf);
|
||||
shfunctab->addnode(shfunctab, ztrdup(funcname), shf);
|
||||
}
|
||||
if (*argv)
|
||||
if (*argv) {
|
||||
zsfree(shf->filename);
|
||||
shf->filename = ztrdup(*argv);
|
||||
}
|
||||
shf->node.flags = on;
|
||||
ret = eval_autoload(shf, funcname, ops, func);
|
||||
}
|
||||
|
|
|
@ -5204,6 +5204,7 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
|
|||
else
|
||||
shf->funcdef = dupeprog(prog, 0);
|
||||
shf->node.flags &= ~PM_UNDEFINED;
|
||||
zsfree(shf->filename);
|
||||
shf->filename = fname;
|
||||
} else {
|
||||
VARARR(char, n, strlen(shf->node.nam) + 1);
|
||||
|
@ -5227,6 +5228,7 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
|
|||
else
|
||||
shf->funcdef = dupeprog(stripkshdef(prog, shf->node.nam), 0);
|
||||
shf->node.flags &= ~PM_UNDEFINED;
|
||||
zsfree(shf->filename);
|
||||
shf->filename = fname;
|
||||
}
|
||||
popheap();
|
||||
|
|
Loading…
Reference in New Issue