]> granicus.if.org Git - vim/commitdiff
patch 8.1.1409: Coverity warns for using uninitialized memory v8.1.1409
authorBram Moolenaar <Bram@vim.org>
Mon, 27 May 2019 18:01:41 +0000 (20:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 27 May 2019 18:01:41 +0000 (20:01 +0200)
Problem:    Coverity warns for using uninitialized memory.
Solution:   Add a condition to clearing the growarray.

src/json.c
src/version.c

index 8674bf26595bc18beb03b7105994d124574fcd98..3a5de7092c957d354cd3e9a4ed6fb46f1fbc5114 100644 (file)
@@ -455,7 +455,8 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
                             STR2NR_HEX + STR2NR_FORCE, &nr, NULL, 4, TRUE);
                    if (len == 0)
                    {
-                       ga_clear(&ga);
+                       if (res != NULL)
+                           ga_clear(&ga);
                        return FAIL;
                    }
                    p += len + 2;
@@ -471,7 +472,8 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
                             STR2NR_HEX + STR2NR_FORCE, &nr2, NULL, 4, TRUE);
                        if (len == 0)
                        {
-                           ga_clear(&ga);
+                           if (res != NULL)
+                               ga_clear(&ga);
                            return FAIL;
                        }
                        if (0xdc00 <= nr2 && nr2 <= 0xdfff)
@@ -484,6 +486,7 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
                    if (res != NULL)
                    {
                        char_u  buf[NUMBUFLEN];
+
                        buf[utf_char2bytes((int)nr, buf)] = NUL;
                        ga_concat(&ga, buf);
                    }
index 5345a5fdc38174d07f3fa8f9060949dd7a86d3b3..b0068641235a0941124a3aa0abbe988a41ca4100 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1409,
 /**/
     1408,
 /**/