From d0754d14664b10404406c61bd20e20506fb1f0a4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 7 Apr 2026 13:55:12 -1000 Subject: [PATCH] [core] Fix TemplatableValue move: destroy moved-from value for non-trivial T --- esphome/core/automation.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/core/automation.h b/esphome/core/automation.h index a89a16aa0a8..af730c35453 100644 --- a/esphome/core/automation.h +++ b/esphome/core/automation.h @@ -101,6 +101,7 @@ template class TemplatableValue { TemplatableValue(TemplatableValue &&other) noexcept : tag_(other.tag_) { if (this->tag_ == VALUE) { new (&this->value_) T(std::move(other.value_)); + other.destroy_(); } else if (this->tag_ == FN) { this->f_ = other.f_; } @@ -126,6 +127,7 @@ template class TemplatableValue { this->tag_ = other.tag_; if (this->tag_ == VALUE) { new (&this->value_) T(std::move(other.value_)); + other.destroy_(); } else if (this->tag_ == FN) { this->f_ = other.f_; }