fix(ui): home-page nav buffer must size to HomePage::Count after FAVOURITES

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 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-25 12:59:32 +02:00
parent 183abcba32
commit d55ae5c2c5

View File

@@ -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);