match it to upstream change

This commit is contained in:
J. Nick Koston
2026-01-02 20:20:02 -10:00
parent 61692894e1
commit 40b09e8cd4

View File

@@ -1714,12 +1714,12 @@ void APIConnection::on_home_assistant_state_response(const HomeAssistantStateRes
// Create null-terminated state for callback (parse_number needs null-termination)
// HA state max length is 255, so 256 byte buffer covers all cases
char state_buf[256];
size_t copy_len = msg.state.size();
size_t copy_len = msg.state_len;
if (copy_len >= sizeof(state_buf)) {
copy_len = sizeof(state_buf) - 1; // Truncate to leave space for null terminator
}
if (copy_len > 0) {
memcpy(state_buf, msg.state.data(), copy_len);
memcpy(state_buf, msg.state, copy_len);
}
state_buf[copy_len] = '\0';
it.callback(StringRef(state_buf, copy_len));