Size the stack copy from the table's MAX_LENGTH

This commit is contained in:
J. Nick Koston
2026-10-13 11:17:19 -10:00
parent 10d89acfa2
commit c42ef0fa1e
+1 -2
View File
@@ -44,10 +44,9 @@ PROGMEM_STRING_TABLE(DosingModeStrings, "None", "Volume", "Volume/Time", "Consta
static void publish_dosing_mode(text_sensor::TextSensor *sensor, DosingMode mode) {
if (sensor == nullptr)
return;
char text[20];
char text[DosingModeStrings::MAX_LENGTH + 1];
ESPHOME_strncpy_P(text, reinterpret_cast<ESPHOME_PGM_P>(DosingModeStrings::get_progmem_str(mode, DOSING_MODE_NONE)),
sizeof(text));
text[sizeof(text) - 1] = '\0';
if (sensor->state != text)
sensor->publish_state(text);
}