changeset 7716:9d79943791ea v7.4.1156

commit https://github.com/vim/vim/commit/2dedb45260604911035cff2364aca90a69156ed9 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 23 21:38:51 2016 +0100 patch 7.4.1156 Problem: Coverity warns for NULL pointer and ignoring return value. Solution: Check for NULL pointer. When dict_add() returns FAIL free the item.
author Christian Brabandt <cb@256bit.org>
date Sat, 23 Jan 2016 21:45:04 +0100
parents a1465a06a3e4
children 9ad4ca70bcea
files src/json.c src/version.c
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/json.c
+++ b/src/json.c
@@ -318,7 +318,8 @@ json_decode_object(js_read_T *reader, ty
 	    goto fail;
 	}
 	di->di_tv = item;
-	dict_add(res->vval.v_dict, di);
+	if (dict_add(res->vval.v_dict, di) == FAIL)
+	    dictitem_free(di);
 
 	json_skip_white(reader);
 	p = reader->js_buf + reader->js_used;
@@ -398,7 +399,10 @@ json_decode_string(js_read_T *reader, ty
     {
 	++reader->js_used;
 	res->v_type = VAR_STRING;
-	res->vval.v_string = vim_strsave(ga.ga_data);
+	if (ga.ga_data == NULL)
+	    res->vval.v_string = NULL;
+	else
+	    res->vval.v_string = vim_strsave(ga.ga_data);
     }
     else
     {
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1156,
+/**/
     1155,
 /**/
     1154,