From 358819bf2ed5974f0cf62e942ecbaae86d90c043 Mon Sep 17 00:00:00 2001 From: -10 Date: Mon, 23 Mar 2026 21:05:06 +0800 Subject: [PATCH] change to use cJSON_ParseWithLength (#1873) --- main/protocols/websocket_protocol.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/protocols/websocket_protocol.cc b/main/protocols/websocket_protocol.cc index f0cc034..4b74a5e 100644 --- a/main/protocols/websocket_protocol.cc +++ b/main/protocols/websocket_protocol.cc @@ -147,7 +147,7 @@ bool WebsocketProtocol::OpenAudioChannel() { } } else { // Parse JSON data - auto root = cJSON_Parse(data); + auto root = cJSON_ParseWithLength(data, len); auto type = cJSON_GetObjectItem(root, "type"); if (cJSON_IsString(type)) { if (strcmp(type->valuestring, "hello") == 0) { @@ -158,7 +158,7 @@ bool WebsocketProtocol::OpenAudioChannel() { } } } else { - ESP_LOGE(TAG, "Missing message type, data: %s", data); + ESP_LOGE(TAG, "Missing message type, data: %s", std::string(data, len).c_str()); } cJSON_Delete(root); }