修复BUG "天气 JSON解析错误 导致系统开机死机"
authorpenglei <1624952103@qq.com>
Wed, 4 Sep 2024 02:40:59 +0000 (10:40 +0800)
committerpenglei <1624952103@qq.com>
Wed, 4 Sep 2024 02:40:59 +0000 (10:40 +0800)
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c

index 429c889..2a929da 100644 (file)
@@ -2161,7 +2161,11 @@ uint8_t parse_jsonCheck_weather(uint8_t *buf,uint8_t *check)//json 格式解析
     }\r
     printf("开始解析天气 JSON\n");\r
     cJSON *now_cjson = cJSON_GetObjectItem(root, "now");\r
-    \r
+    if(now_cjson == NULL)\r
+    {\r
+        printf("天气 JSON解析错误\n");\r
+        return 0;\r
+    }\r
     int humidity = cJSON_GetObjectItem(now_cjson, "humidity")->valueint;\r
     char * windScale = cJSON_GetObjectItem(now_cjson, "windScale")->valuestring;\r
     char *textNight = cJSON_GetObjectItem(now_cjson, "textNight")->valuestring;\r