[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
This commit is contained in:
William Wilgus 2026-06-17 13:30:51 -04:00
parent 7154fcd9a8
commit ca2edad012
2 changed files with 6 additions and 5 deletions

View file

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

View file

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