Mercurial > vim
changeset 19077:568cce19fd2b v8.2.0099
patch 8.2.0099: use of NULL pointer when out of memory
Commit: https://github.com/vim/vim/commit/8b7aa2f9b238df916c161cdacda032c25d72a0ae
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 7 21:05:49 2020 +0100
patch 8.2.0099: use of NULL pointer when out of memory
Problem: Use of NULL pointer when out of memory.
Solution: Check for NULL pointer. (Dominique Pelle, closes https://github.com/vim/vim/issues/5449)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 07 Jan 2020 21:15:06 +0100 |
parents | 7d20bed8cd8c |
children | 979b303031ca |
files | src/cmdexpand.c src/version.c |
diffstat | 2 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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);