mirror of
https://github.com/esphome/esphome.git
synced 2025-10-24 12:43:51 +01:00
nullptr
This commit is contained in:
@@ -290,6 +290,9 @@ class Scheduler {
|
|||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (auto &item : container) {
|
for (auto &item : container) {
|
||||||
// Skip nullptr items (can happen in defer_queue_ when items are being processed)
|
// Skip nullptr items (can happen in defer_queue_ when items are being processed)
|
||||||
|
// The defer_queue_ uses index-based processing: items are std::moved out but left in the
|
||||||
|
// vector as nullptr until cleanup. If cancel_item_locked_() is called from a callback during
|
||||||
|
// defer queue processing, it will iterate over these nullptr items. This check prevents crashes.
|
||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
if (this->matches_item_(item, component, name_cstr, type, match_retry)) {
|
if (this->matches_item_(item, component, name_cstr, type, match_retry)) {
|
||||||
@@ -315,6 +318,9 @@ class Scheduler {
|
|||||||
bool match_retry) const {
|
bool match_retry) const {
|
||||||
for (const auto &item : container) {
|
for (const auto &item : container) {
|
||||||
// Skip nullptr items (can happen in defer_queue_ when items are being processed)
|
// Skip nullptr items (can happen in defer_queue_ when items are being processed)
|
||||||
|
// The defer_queue_ uses index-based processing: items are std::moved out but left in the
|
||||||
|
// vector as nullptr until cleanup. If this function is called during defer queue processing,
|
||||||
|
// it will iterate over these nullptr items. This check prevents crashes.
|
||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
if (is_item_removed_(item.get()) &&
|
if (is_item_removed_(item.get()) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user