mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
sb_create_from_settings: Fix crash when ui viewport setting malformed
The 'Purple_Glow_V3' theme uses the following 'UI viewport' setting which is missing a comma after the viewport height: ui viewport: 0,0,271,212-,-,- The setting is actually ignored when loading this theme, since a UI viewport is already defined in the supplied SBS file. Rockbox will crash, though, when and if the next theme that is loaded resets the SBS by setting it to "-", but doesn't adjust the UI viewport setting at the same time. To fix, use default UI viewport when encountering fewer parameters than expected for the UI viewport setting. Change-Id: I2648565ac59369ce8ab18d8e84b7fa69ad767f25
This commit is contained in:
parent
325d71a579
commit
2b30a9fed8
1 changed files with 10 additions and 4 deletions
|
@ -252,22 +252,28 @@ char* sb_create_from_settings(enum screen_type screen)
|
|||
comma = strchr(comma+1, ',');
|
||||
|
||||
} while (comma && param_count < 6);
|
||||
if (comma)
|
||||
if (comma && strchr(comma+1, ','))
|
||||
{
|
||||
char *end = comma;
|
||||
char fg[8], bg[8];
|
||||
int i = 0;
|
||||
comma++;
|
||||
while (*comma != ',')
|
||||
while (*comma != ',' && i < (int) sizeof(fg) - 1)
|
||||
fg[i++] = *comma++;
|
||||
fg[i] = '\0'; comma++; i=0;
|
||||
while (*comma != ')')
|
||||
while (*comma != ')' && i < (int) sizeof(bg) - 1)
|
||||
bg[i++] = *comma++;
|
||||
bg[i] = '\0';
|
||||
len += snprintf(end, remaining-len, ") %%Vf(%s) %%Vb(%s)\n", fg, bg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr2[0] = '-';
|
||||
ptr2[1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (!ptr2[0] || ptr2[0] == '-')
|
||||
{
|
||||
int y = 0, height;
|
||||
switch (bar_position)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue