mirror of
https://github.com/esphome/esphome.git
synced 2026-02-28 18:04:19 -07:00
6a7925b3cea591e8a22f92ab99a4da7542436cab
ArduinoJson's serializeJson() with a bounded buffer returns the actual bytes written (truncated count), NOT the would-be size like snprintf(). When the payload exceeded the 512-byte stack buffer, the return value was used as the exact size for heap reallocation, but this was only the truncated count. The heap buffer was allocated too small, the second serialization was also truncated, and no NUL terminator was written. This caused corrupted JSON in SSE streams for entities with payloads exceeding 512 bytes (e.g., climate DETAIL_ALL with many features). Fix: use measureJson() in the heap fallback path to get the exact untruncated size before allocating. Also add the missing set_size_() call after the second serialization to ensure proper NUL termination.
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
518 MiB
Languages
C++
64.1%
Python
35.5%
C
0.3%
