diff options
| author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2016-11-17 19:49:17 +0000 |
|---|---|---|
| committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2016-11-17 19:49:17 +0000 |
| commit | a62e1640bcafbb82d86ea8d8ce057a83c4683d60 (patch) | |
| tree | b2e99365eb00070fd5b51f45d9cbb14fb1a17fd4 /Src/compat.c | |
| parent | 39921: __git_recent_branches: Remove erroneous parsing of partial ref names a... (diff) | |
| download | zsh-a62e1640bcafbb82d86ea8d8ce057a83c4683d60.tar zsh-a62e1640bcafbb82d86ea8d8ce057a83c4683d60.tar.gz zsh-a62e1640bcafbb82d86ea8d8ce057a83c4683d60.tar.bz2 zsh-a62e1640bcafbb82d86ea8d8ce057a83c4683d60.tar.lz zsh-a62e1640bcafbb82d86ea8d8ce057a83c4683d60.tar.xz zsh-a62e1640bcafbb82d86ea8d8ce057a83c4683d60.tar.zst zsh-a62e1640bcafbb82d86ea8d8ce057a83c4683d60.zip | |
39958: Add extra byte to PATH_MAX allocations.
This ensures we've got enough space for a null, although this
isn't always needed.
Diffstat (limited to 'Src/compat.c')
| -rw-r--r-- | Src/compat.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Src/compat.c b/Src/compat.c index 9041c0bed..81afd4dfd 100644 --- a/Src/compat.c +++ b/Src/compat.c @@ -270,7 +270,7 @@ zgetdir(struct dirsav *d) int len; #endif - buf = zhalloc(bufsiz = PATH_MAX); + buf = zhalloc(bufsiz = PATH_MAX+1); pos = bufsiz - 1; buf[pos] = '\0'; strcpy(nbuf, "../"); @@ -439,11 +439,11 @@ zgetcwd(void) free(cwd); } #else - char *cwdbuf = zalloc(PATH_MAX); + char *cwdbuf = zalloc(PATH_MAX+1); ret = getcwd(cwdbuf, PATH_MAX); if (ret) ret = dupstring(ret); - zfree(cwdbuf, PATH_MAX); + zfree(cwdbuf, PATH_MAX+1); #endif /* GETCWD_CALLS_MALLOC */ } #endif /* HAVE_GETCWD */ |
