diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-01-23 21:38:51 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-01-23 21:38:51 +0100 |
commit | 2dedb45260604911035cff2364aca90a69156ed9 (patch) | |
tree | 209a72a5e113fa9b65ee8dfeb9ab4f0db2ae3997 /src/json.c | |
parent | 64922b9014765a41bb09e8612433a2a61918af6e (diff) | |
download | vim-git-2dedb45260604911035cff2364aca90a69156ed9.tar.gz |
patch 7.4.1156v7.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.
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/json.c b/src/json.c index 7b67994dd..442eaff2c 100644 --- a/src/json.c +++ b/src/json.c @@ -318,7 +318,8 @@ json_decode_object(js_read_T *reader, typval_T *res) 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, typval_T *res) { ++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 { |