From 787af59845000a62889446868c0cadd811be94a5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 27 Mar 2026 15:55:29 -1000 Subject: [PATCH] [text_sensor] Assert size before writing, not after --- esphome/components/text_sensor/filter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/text_sensor/filter.h b/esphome/components/text_sensor/filter.h index f4bb0228c57..ae3307f5ed2 100644 --- a/esphome/components/text_sensor/filter.h +++ b/esphome/components/text_sensor/filter.h @@ -131,11 +131,11 @@ bool substitute_filter_apply(const Substitution *substitutions, size_t count, st template class SubstituteFilter : public Filter { public: explicit SubstituteFilter(const std::initializer_list &substitutions) { + ESPHOME_DEBUG_ASSERT(substitutions.size() == N); size_t i = 0; for (const auto &s : substitutions) { this->substitutions_[i++] = s; } - ESPHOME_DEBUG_ASSERT(i == N); } bool new_value(std::string &value) override { return substitute_filter_apply(this->substitutions_.data(), N, value); }