change to use cJSON_ParseWithLength (#1873)
This commit is contained in:
@ -147,7 +147,7 @@ bool WebsocketProtocol::OpenAudioChannel() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Parse JSON data
|
// Parse JSON data
|
||||||
auto root = cJSON_Parse(data);
|
auto root = cJSON_ParseWithLength(data, len);
|
||||||
auto type = cJSON_GetObjectItem(root, "type");
|
auto type = cJSON_GetObjectItem(root, "type");
|
||||||
if (cJSON_IsString(type)) {
|
if (cJSON_IsString(type)) {
|
||||||
if (strcmp(type->valuestring, "hello") == 0) {
|
if (strcmp(type->valuestring, "hello") == 0) {
|
||||||
@ -158,7 +158,7 @@ bool WebsocketProtocol::OpenAudioChannel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
cJSON_Delete(root);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user