change to use cJSON_ParseWithLength (#1873)

This commit is contained in:
-10
2026-03-23 21:05:06 +08:00
committed by GitHub
parent cef581d723
commit 358819bf2e

View File

@ -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);
}