mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user