summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-27 20:01:41 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-27 20:01:41 +0200
commitb43683729b64f83c39840524be232388314bd71f (patch)
treebf0f8e15a52243098dc9a59d8b40c530a2216c6b /src/json.c
parentbf0ecb2cb63fb710198d6be742ae4f00fdd2f948 (diff)
downloadvim-git-b43683729b64f83c39840524be232388314bd71f.tar.gz
patch 8.1.1409: Coverity warns for using uninitialized memoryv8.1.1409
Problem: Coverity warns for using uninitialized memory. Solution: Add a condition to clearing the growarray.
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/json.c b/src/json.c
index 8674bf265..3a5de7092 100644
--- a/src/json.c
+++ b/src/json.c
@@ -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);
}