mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-23 17:01:05 +02:00
12847: dynamically allocate buf and z in bin_whence()
This commit is contained in:
parent
946085efa5
commit
9f012ce7c9
2 changed files with 9 additions and 8 deletions
|
@ -1,5 +1,8 @@
|
||||||
2000-09-19 Clint Adams <schizo@debian.org>
|
2000-09-19 Clint Adams <schizo@debian.org>
|
||||||
|
|
||||||
|
* 12847: Src/builtin.c: dynamically allocate z and buf in
|
||||||
|
bin_whence().
|
||||||
|
|
||||||
* 12846: Src/.distfiles, Src/mem.c, Src/string.c, Src/utils.c,
|
* 12846: Src/.distfiles, Src/mem.c, Src/string.c, Src/utils.c,
|
||||||
Src/zsh.mdd: Move dupstring(), ztrdup(), tricat(), zhtricat(),
|
Src/zsh.mdd: Move dupstring(), ztrdup(), tricat(), zhtricat(),
|
||||||
dyncat(), dupstrpfx(), ztrduppfx(), and appstr() to string.c.
|
dyncat(), dupstrpfx(), ztrduppfx(), and appstr() to string.c.
|
||||||
|
|
|
@ -2390,17 +2390,14 @@ bin_whence(char *nam, char **argv, char *ops, int func)
|
||||||
/* Option -a is to search the entire path, *
|
/* Option -a is to search the entire path, *
|
||||||
* rather than just looking for one match. */
|
* rather than just looking for one match. */
|
||||||
if (all) {
|
if (all) {
|
||||||
char **pp, buf[PATH_MAX], *z;
|
char **pp, *buf, *z;
|
||||||
|
|
||||||
|
pushheap();
|
||||||
for (pp = path; *pp; pp++) {
|
for (pp = path; *pp; pp++) {
|
||||||
z = buf;
|
|
||||||
if (**pp) {
|
if (**pp) {
|
||||||
strucpy(&z, *pp);
|
z = dyncat(*pp, "/");
|
||||||
*z++ = '/';
|
} else z = NULL;
|
||||||
}
|
buf = dyncat(z, *argv);
|
||||||
if ((z - buf) + strlen(*argv) >= PATH_MAX)
|
|
||||||
continue;
|
|
||||||
strcpy(z, *argv);
|
|
||||||
if (iscom(buf)) {
|
if (iscom(buf)) {
|
||||||
if (wd) {
|
if (wd) {
|
||||||
printf("%s: command\n", *argv);
|
printf("%s: command\n", *argv);
|
||||||
|
@ -2420,6 +2417,7 @@ bin_whence(char *nam, char **argv, char *ops, int func)
|
||||||
puts(wd ? ": none" : " not found");
|
puts(wd ? ": none" : " not found");
|
||||||
returnval = 1;
|
returnval = 1;
|
||||||
}
|
}
|
||||||
|
popheap();
|
||||||
} else if ((cnam = findcmd(*argv, 1))) {
|
} else if ((cnam = findcmd(*argv, 1))) {
|
||||||
/* Found external command. */
|
/* Found external command. */
|
||||||
if (wd) {
|
if (wd) {
|
||||||
|
|
Loading…
Reference in a new issue