From 89d6011d7376d19fd4b9710cfde86181409ff425 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Tue, 18 Feb 2025 16:56:23 +0100 Subject: [PATCH] fix: initialize lamp_list to prevent returning uninitialized values in build_lamp_list_from_list_str_ --- esphome/components/dynamic_lamp/dynamic_lamp.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.cpp b/esphome/components/dynamic_lamp/dynamic_lamp.cpp index 908a2fe9dc..f59ab05a92 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.cpp +++ b/esphome/components/dynamic_lamp/dynamic_lamp.cpp @@ -273,14 +273,20 @@ LampList DynamicLampComponent::build_lamp_list_from_list_str_(std::string lamp_l if (lamp_list_vector.size() > 16) { ESP_LOGW(TAG, "Too many lamps in list, only 16 supported!"); this->status_set_warning(); - return LampList(); + LampList lamp_list; + lamp_list[0] = 0; + lamp_list[1] = 0; + return lamp_list(); } LampList lamp_list; for (uint8_t i = 0; i < lamp_list_vector.size(); i++) { if (lamp_list_vector[i] > 15) { ESP_LOGW(TAG, "Lamp index %" PRIu8 " is out of range, only [0-15] supported!", lamp_list_vector[i]); this->status_set_warning(); - return LampList(); + LampList lamp_list; + lamp_list[0] = 0; + lamp_list[1] = 0; + return lamp_list(); } switch (lamp_list_vector[i]) { case 0: