diff --git a/esphome/core/scheduler.cpp b/esphome/core/scheduler.cpp index 285354b262..2086f5e3dd 100644 --- a/esphome/core/scheduler.cpp +++ b/esphome/core/scheduler.cpp @@ -226,9 +226,10 @@ void HOT Scheduler::call() { // - No deferred items exist in to_add_, so processing order doesn't affect correctness while (!this->defer_queue_.empty()) { this->lock_.lock(); - if (this->defer_queue_.empty()) // Double-check with lock held + if (this->defer_queue_.empty()) { // Double-check with lock held this->lock_.unlock(); - break; + break; + } auto item = std::move(this->defer_queue_.front()); this->defer_queue_.pop_front(); this->lock_.unlock();