Skip to content

Commit 2dedb45

Browse files
committed
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.
1 parent 64922b9 commit 2dedb45

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/json.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ json_decode_object(js_read_T *reader, typval_T *res)
318318
goto fail;
319319
}
320320
di->di_tv = item;
321-
dict_add(res->vval.v_dict, di);
321+
if (dict_add(res->vval.v_dict, di) == FAIL)
322+
dictitem_free(di);
322323

323324
json_skip_white(reader);
324325
p = reader->js_buf + reader->js_used;
@@ -398,7 +399,10 @@ json_decode_string(js_read_T *reader, typval_T *res)
398399
{
399400
++reader->js_used;
400401
res->v_type = VAR_STRING;
401-
res->vval.v_string = vim_strsave(ga.ga_data);
402+
if (ga.ga_data == NULL)
403+
res->vval.v_string = NULL;
404+
else
405+
res->vval.v_string = vim_strsave(ga.ga_data);
402406
}
403407
else
404408
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1156,
744746
/**/
745747
1155,
746748
/**/

0 commit comments

Comments
 (0)