diff options
author | Clint Adams <clint@users.sourceforge.net> | 2000-09-22 22:16:15 +0000 |
---|---|---|
committer | Clint Adams <clint@users.sourceforge.net> | 2000-09-22 22:16:15 +0000 |
commit | 2a625db39df5e5e5f72556f0cd4a02005115c50f (patch) | |
tree | 9eb6be89333525ea9c74c14887da7a37aa8739cb /Src/Zle | |
parent | 430e2947951207e45b02ba1ebc04586d06ade021 (diff) | |
download | zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar.gz zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar.xz zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.zip |
12859: dynamically-allocate buffer in ztat(), ztrdupstring()
Diffstat (limited to 'Src/Zle')
-rw-r--r-- | Src/Zle/compresult.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 19d785bb8..92bb2c803 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -731,19 +731,17 @@ do_ambiguous(void) mod_export int ztat(char *nam, struct stat *buf, int ls) { - char b[PATH_MAX], *p; + int e; + char *b; if (!(ls ? lstat(nam, buf) : stat(nam, buf))) return 0; - for (p = b; p < b + sizeof(b) - 1 && *nam; nam++) - if (*nam == '\\' && nam[1]) - *p++ = *++nam; - else - *p++ = *nam; - *p = '\0'; + b = ztrdupstrip(nam, '\\'); - return ls ? lstat(b, buf) : stat(b, buf); + e = ls ? lstat(b, buf) : stat(b, buf); + zsfree(b); + return e; } /* Insert a single match in the command line. */ |