diff --git a/src/BaseItemManyWidgets.h b/src/BaseItemManyWidgets.h index 5d3af5d7..afbe1b91 100644 --- a/src/BaseItemManyWidgets.h +++ b/src/BaseItemManyWidgets.h @@ -61,12 +61,7 @@ class BaseItemManyWidgets : public MenuItem { uint8_t cursorCol = 0; for (uint8_t i = 0; i < size; i++) { - uint8_t drawn = widgets[i]->draw(buf, index); - if (index + drawn >= ITEM_DRAW_BUFFER_SIZE) { - // Handle buffer overflow (stop drawing remaining widgets) - break; - } - index += drawn; + index += widgets[i]->draw(buf, index); if (i == activeWidget && renderer->isInEditMode()) { renderer->drawItem(text, buf); cursorCol = renderer->getCursorCol() - 1 - widgets[i]->cursorOffset; diff --git a/src/widget/BaseWidgetValue.h b/src/widget/BaseWidgetValue.h index d560c60d..9d4b2019 100644 --- a/src/widget/BaseWidgetValue.h +++ b/src/widget/BaseWidgetValue.h @@ -46,6 +46,7 @@ class BaseWidgetValue : public BaseWidget { * @param start the index where to start drawing in the buffer */ uint8_t draw(char* buffer, const uint8_t start) override { + if (start >= ITEM_DRAW_BUFFER_SIZE) return 0; return snprintf(buffer + start, ITEM_DRAW_BUFFER_SIZE, format, value); }