From 3cfca5228c1cde5cb8c6810f7e64cc4f5f0cc6bf Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Jan 2026 08:45:10 -1000 Subject: [PATCH] bot review --- esphome/core/string_ref.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/core/string_ref.h b/esphome/core/string_ref.h index 3b209a7c7f..59aedbebda 100644 --- a/esphome/core/string_ref.h +++ b/esphome/core/string_ref.h @@ -87,7 +87,8 @@ class StringRef { if (pos >= len_) return std::string::npos; const char *result = std::strstr(base_ + pos, s); - return result ? static_cast(result - base_) : std::string::npos; + // Verify match is within bounds (strstr searches to null terminator) + return (result && result < base_ + len_) ? static_cast(result - base_) : std::string::npos; } size_type find(char c, size_type pos = 0) const { if (pos >= len_)