From 1bdcf368c6a1aac228393c5da287bc89da8e5625 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 8 Apr 2021 12:03:20 +0800 Subject: [PATCH] Init valueint and valuedouble incase of cJSON_False/cJSON_True/cJSON_NULL Signed-off-by: Xiang Xiao Change-Id: If75627ce38b9798498dd2a82013a70049a2a7e76 --- cJSON.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cJSON.c b/cJSON.c index 030311c..a8d7888 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1317,6 +1317,8 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0)) { item->type = cJSON_NULL; + item->valueint = 0; + item->valuedouble = 0; input_buffer->offset += 4; return true; } @@ -1324,6 +1326,8 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0)) { item->type = cJSON_False; + item->valueint = 0; + item->valuedouble = 0; input_buffer->offset += 5; return true; } @@ -1332,6 +1336,7 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf { item->type = cJSON_True; item->valueint = 1; + item->valuedouble = 1; input_buffer->offset += 4; return true; }