From ca2edad0123c1f3002aeda80a4e2128519105086 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 17 Jun 2026 13:30:51 -0400 Subject: [PATCH] [Bugfix] FS#13926 -lua Crash when displaying error splash fix lua strpbrk function skipping the first accept chr lua splash_scroller fix NULL pointer in brk due to lastbreak not being reset on a new line Change-Id: Ica0c9ee5f9194f5be54ab90ad16309adead1c207 --- apps/plugins/lua/rockaux.c | 7 ++++--- apps/plugins/lua/strpbrk.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c index 5317d23be9..1cfd31805c 100644 --- a/apps/plugins/lua/rockaux.c +++ b/apps/plugins/lua/rockaux.c @@ -79,7 +79,7 @@ int splash_scroller(int timeout, const char* str) const int max_ch = (LCD_WIDTH / ch_w - 1) * 2; char line[max_ch + 2]; /* display buffer +2 incase of tab chars */ - const char break_chars[] = "/\\ \r\n\f\v"; + const char break_chars[] = "/\\ \r\n\f\v"; const char *ch, *brk; int linepos, curline, linesdisp, maxl, last_break; @@ -100,7 +100,7 @@ int splash_scroller(int timeout, const char* str) linepos = 0; brk = NULL; maxl = rb->font_measurestring(ch, max_ch, max_w, &w, NULL, fontnum); - for (; *ch && linepos < maxl; ch++) + for (; *ch && linepos <= maxl; ch++) { if (strpbrk_n(ch, 1, break_chars)) { @@ -143,7 +143,7 @@ int splash_scroller(int timeout, const char* str) /* try to not split in middle of words */ if (last_break > 0 && *ch != '\0') { - if (strpbrk_n(ch, 1, break_chars) || + if ((!strpbrk_n(ch, 1, break_chars)) && (w + wrap_thresh > max_w && strpbrk_n(ch, max_ch, break_chars))) { line[last_break] = '\0'; @@ -155,6 +155,7 @@ int splash_scroller(int timeout, const char* str) { lcd_putsxy(0, realline * ch_h, line); linesdisp++; + last_break = 0; } curline++; diff --git a/apps/plugins/lua/strpbrk.c b/apps/plugins/lua/strpbrk.c index efa9cbd2bb..9870b3753a 100644 --- a/apps/plugins/lua/strpbrk.c +++ b/apps/plugins/lua/strpbrk.c @@ -6,8 +6,8 @@ const char *strpbrk_n(const char *s, int smax, const char *accept) { register int i; register const char *a = accept; for (i=0; __likely(s[i] && i < smax); i++, a=accept) - while(__likely(a++[0])) - if ((s[i] == a[0])) + while(__likely(a[0])) + if ((s[i] == a++[0])) return &s[i]; return NULL; }