From 67e7ba4812cd32caf4f34e001a2686056c482f19 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 6 Feb 2026 23:12:00 +0100 Subject: [PATCH] handle unlikely --- esphome/components/cse7766/cse7766.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/cse7766/cse7766.cpp b/esphome/components/cse7766/cse7766.cpp index 2868af5152..ae4b9c9316 100644 --- a/esphome/components/cse7766/cse7766.cpp +++ b/esphome/components/cse7766/cse7766.cpp @@ -27,7 +27,9 @@ void CSE7766Component::loop() { uint8_t buf[CSE7766_RAW_DATA_SIZE]; while (avail > 0) { size_t to_read = std::min(static_cast(avail), sizeof(buf)); - this->read_array(buf, to_read); + if (!this->read_array(buf, to_read)) { + break; + } avail -= to_read; for (size_t i = 0; i < to_read; i++) {