From 3a6a66537c97189b99b2fddc79f8cf38274d52fe Mon Sep 17 00:00:00 2001 From: Ben Winslow Date: Mon, 18 Aug 2025 20:20:13 -0400 Subject: [PATCH] [nextion] Don't include terminating NUL in nextion text_sensor states (#10273) --- esphome/components/nextion/nextion.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/nextion/nextion.cpp b/esphome/components/nextion/nextion.cpp index 133bd2947c..b348bc9920 100644 --- a/esphome/components/nextion/nextion.cpp +++ b/esphome/components/nextion/nextion.cpp @@ -764,7 +764,8 @@ void Nextion::process_nextion_commands_() { variable_name = to_process.substr(0, index); ++index; - text_value = to_process.substr(index); + // Get variable value without terminating NUL byte. Length check above ensures substr len >= 0. + text_value = to_process.substr(index, to_process_length - index - 1); ESP_LOGN(TAG, "Text sensor: %s='%s'", variable_name.c_str(), text_value.c_str());