]> granicus.if.org Git - vim/commitdiff
patch 8.2.0099: use of NULL pointer when out of memory v8.2.0099
authorBram Moolenaar <Bram@vim.org>
Tue, 7 Jan 2020 20:05:49 +0000 (21:05 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 7 Jan 2020 20:05:49 +0000 (21:05 +0100)
Problem:    Use of NULL pointer when out of memory.
Solution:   Check for NULL pointer. (Dominique Pelle, closes #5449)

src/cmdexpand.c
src/version.c

index 210b5f9819a2222db970f525785f7ccd44918d96..b5da922fd181837cc8c97ae13c59214413b6acff 100644 (file)
@@ -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);
index c466c29b243215fbe4cef89824d4bf003063f4d3..8322eb31de3565b954b508a2e2f77b98b4fb4be5 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    99,
 /**/
     98,
 /**/