1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00

[scheduler] Fix cancellation of timers with empty string names (#9641)

This commit is contained in:
J. Nick Koston
2025-07-17 16:20:35 -10:00
committed by GitHub
parent eb8a241a01
commit 158a3b2835
5 changed files with 123 additions and 12 deletions

View File

@@ -121,16 +121,17 @@ class Scheduler {
name_is_dynamic = false;
}
if (!name || !name[0]) {
if (!name) {
// nullptr case - no name provided
name_.static_name = nullptr;
} else if (make_copy) {
// Make a copy for dynamic strings
// Make a copy for dynamic strings (including empty strings)
size_t len = strlen(name);
name_.dynamic_name = new char[len + 1];
memcpy(name_.dynamic_name, name, len + 1);
name_is_dynamic = true;
} else {
// Use static string directly
// Use static string directly (including empty strings)
name_.static_name = name;
}
}