From 6389271bfcb08b24e2917bde52a392e107133896 Mon Sep 17 00:00:00 2001 From: wangfq Date: Tue, 30 Jun 2026 18:52:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20simple=5Fjson=20=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=9C=AB=E5=B0=BE=E5=AF=B9=E8=B1=A1=E5=80=BC=E6=97=B6=20y=20?= =?UTF-8?q?=E6=9C=AA=E8=B5=8B=E5=80=BC=20+=20=E7=BC=BA=E5=B0=91=20'}'=20?= =?UTF-8?q?=E5=85=9C=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 两处修复 (simple_parse_json & simple_json_getarray_item): 1. if(y==NULL) strstr(q,"}\n") → if(y==NULL) y = strstr(q,"}\n") (缺失 y = 导致 strlen(NULL) 崩溃) 2. 新增 if(y==NULL) y = strchr(q, '}') (JSON 末尾对象值 "data":{...}} 只有 }} 无 }, \r\n 时需兜底) --- .../BLE/OnlyUpdateApp_Peripheral/APP/simple_json.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/simple_json.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/simple_json.c index 2c9a43b..162c705 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/simple_json.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/simple_json.c @@ -98,8 +98,9 @@ void simple_parse_json(const char * data, char *key_str, char *value_str) y = strstr(q, "},"); if(y == NULL) { - y = strstr(q, "}\r\n"); - if(y == NULL) strstr(q, "}\n"); + y = strstr(q, "}\r\n"); + if(y == NULL) y = strstr(q, "}\n"); + if(y == NULL) y = strchr(q, '}'); } len = strlen(q) - strlen(y); memcpy(value_str, q, len); @@ -199,8 +200,9 @@ void simple_json_getarray_item(const char * data, char *key_str, char *value_str y = strstr(q, "},"); if(y == NULL) { - y = strstr(q, "}\r\n"); - if(y == NULL) strstr(q, "}\n"); + y = strstr(q, "}\r\n"); + if(y == NULL) y = strstr(q, "}\n"); + if(y == NULL) y = strchr(q, '}'); } len = strlen(q) - strlen(y); memcpy(value_str, q, len);