diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-01-07 21:05:49 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-01-07 21:05:49 +0100 |
commit | 8b7aa2f9b238df916c161cdacda032c25d72a0ae (patch) | |
tree | f10f144886941b4a932b920087da2d404100c449 /src/cmdexpand.c | |
parent | e31ee86859528a7ffe00405645547d494e522fa8 (diff) | |
download | vim-git-8b7aa2f9b238df916c161cdacda032c25d72a0ae.tar.gz |
patch 8.2.0099: use of NULL pointer when out of memoryv8.2.0099
Problem: Use of NULL pointer when out of memory.
Solution: Check for NULL pointer. (Dominique Pelle, closes #5449)
Diffstat (limited to 'src/cmdexpand.c')
-rw-r--r-- | src/cmdexpand.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c index 210b5f981..b5da922fd 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -2327,7 +2327,7 @@ expand_shellcmd( char_u *path = NULL; int mustfree = FALSE; garray_T ga; - char_u *buf = alloc(MAXPATHL); + char_u *buf; size_t l; char_u *s, *e; int flags = flagsarg; @@ -2337,12 +2337,18 @@ expand_shellcmd( hashitem_T *hi; hash_T hash; + buf = alloc(MAXPATHL); if (buf == NULL) return FAIL; - // for ":set path=" and ":set tags=" halve backslashes for escaped - // space + // for ":set path=" and ":set tags=" halve backslashes for escaped space pat = vim_strsave(filepat); + if (pat == NULL) + { + vim_free(buf); + return FAIL; + } + for (i = 0; pat[i]; ++i) if (pat[i] == '\\' && pat[i + 1] == ' ') STRMOVE(pat + i, pat + i + 1); |