From d55ae5c2c5e43a9f3304578c5a2365c91b93fb0e Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Mon, 25 May 2026 12:59:32 +0200 Subject: [PATCH] fix(ui): home-page nav buffer must size to HomePage::Count after FAVOURITES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both call sites of buildVisibleOrder wrote into a fixed-size 11-int stack buffer. After FAVOURITES landed, HomePage::Count became 12; in the common case where all pages are visible, buildVisibleOrder writes 12 entries — one past the end. That OOB write trashed whatever lived next on the stack (typically the loop variable in navPage), so LEFT wrap-around behaved randomly: sometimes locked at the first page, sometimes jumped to a wrong one. User-visible as "menu doesn't wrap to the left". Size the buffer to `(int)Count` so it tracks the enum and grows with any future home page additions. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/UITask.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index b6b758ef..57634c24 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -280,7 +280,7 @@ class HomeScreen : public UIScreen { } int navPage(int from, int dir) const { - int order[11]; int n = buildVisibleOrder(order); + int order[(int)Count]; int n = buildVisibleOrder(order); if (n == 0) return from; int cur = 0; for (int i = 0; i < n; i++) if (order[i] == from) { cur = i; break; } @@ -482,7 +482,7 @@ public: // curr page indicator — hidden on CLOCK page (full screen used for dashboard) if (_page != CLOCK) { - int order[11]; int n = buildVisibleOrder(order); + int order[(int)Count]; int n = buildVisibleOrder(order); int curr_vis = 0; for (int i = 0; i < n; i++) if (order[i] == _page) { curr_vis = i; break; } int x = display.width() / 2 - 5 * (n - 1);