Mercurial > vim
comparison src/cmdexpand.c @ 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 | 463b6fad54e9 |
children | ff5048b0ccfe |
comparison
equal
deleted
inserted
replaced
19076:7d20bed8cd8c | 19077:568cce19fd2b |
---|---|
2325 char_u *pat; | 2325 char_u *pat; |
2326 int i; | 2326 int i; |
2327 char_u *path = NULL; | 2327 char_u *path = NULL; |
2328 int mustfree = FALSE; | 2328 int mustfree = FALSE; |
2329 garray_T ga; | 2329 garray_T ga; |
2330 char_u *buf = alloc(MAXPATHL); | 2330 char_u *buf; |
2331 size_t l; | 2331 size_t l; |
2332 char_u *s, *e; | 2332 char_u *s, *e; |
2333 int flags = flagsarg; | 2333 int flags = flagsarg; |
2334 int ret; | 2334 int ret; |
2335 int did_curdir = FALSE; | 2335 int did_curdir = FALSE; |
2336 hashtab_T found_ht; | 2336 hashtab_T found_ht; |
2337 hashitem_T *hi; | 2337 hashitem_T *hi; |
2338 hash_T hash; | 2338 hash_T hash; |
2339 | 2339 |
2340 buf = alloc(MAXPATHL); | |
2340 if (buf == NULL) | 2341 if (buf == NULL) |
2341 return FAIL; | 2342 return FAIL; |
2342 | 2343 |
2343 // for ":set path=" and ":set tags=" halve backslashes for escaped | 2344 // for ":set path=" and ":set tags=" halve backslashes for escaped space |
2344 // space | |
2345 pat = vim_strsave(filepat); | 2345 pat = vim_strsave(filepat); |
2346 if (pat == NULL) | |
2347 { | |
2348 vim_free(buf); | |
2349 return FAIL; | |
2350 } | |
2351 | |
2346 for (i = 0; pat[i]; ++i) | 2352 for (i = 0; pat[i]; ++i) |
2347 if (pat[i] == '\\' && pat[i + 1] == ' ') | 2353 if (pat[i] == '\\' && pat[i + 1] == ' ') |
2348 STRMOVE(pat + i, pat + i + 1); | 2354 STRMOVE(pat + i, pat + i + 1); |
2349 | 2355 |
2350 flags |= EW_FILE | EW_EXEC | EW_SHELLCMD; | 2356 flags |= EW_FILE | EW_EXEC | EW_SHELLCMD; |