From 084790809f970fce31b61a2a3b4f1a711557d357 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 18 Mar 2026 21:26:20 -1000 Subject: [PATCH] [combination] Add safety comment for [&source] capture lifetime --- esphome/components/combination/combination.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/combination/combination.cpp b/esphome/components/combination/combination.cpp index 27d6af1346b..b858eee4ee4 100644 --- a/esphome/components/combination/combination.cpp +++ b/esphome/components/combination/combination.cpp @@ -60,6 +60,8 @@ void KalmanCombinationComponent::dump_config() { void KalmanCombinationComponent::setup() { for (auto &source : this->sensor_sources_) { + // [&source] is safe: source refers to a FixedVector element that never reallocates, + // so the reference remains valid for the component's lifetime. source.sensor->add_on_state_callback([&source](float x) -> void { static_cast(source.parent)->correct_(x, source.compute(x)); });