mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
[BugFix] gui/list.c simplelist_set_line_count > 1 list buffer corruption
when line was > 0 static item might not be in buffer after 35a913473e
Change-Id: I6fefb16d05d132f8f0e4bbbbfcf471342a434072
This commit is contained in:
parent
35a913473e
commit
d6e3514c0d
1 changed files with 18 additions and 1 deletions
|
|
@ -813,7 +813,24 @@ void simplelist_set_line_count(int lines)
|
|||
simplelist_line_count = 0;
|
||||
}
|
||||
else if (lines < simplelist_line_count) {
|
||||
const char *end = simplelist_text[lines];
|
||||
const char *end = simplelist_buffer;
|
||||
int last_line = 0;
|
||||
const char * const bufend = simplelist_buffer + sizeof(simplelist_buffer);
|
||||
/* find the last item in the buffer we are still showing */
|
||||
for (int line = 0; line <= lines; line++)
|
||||
{
|
||||
const char *first = simplelist_text[line];
|
||||
if (first >= simplelist_buffer && first < bufend)
|
||||
{
|
||||
last_line = line;
|
||||
end = first;
|
||||
}
|
||||
line++;
|
||||
}
|
||||
|
||||
if (last_line < lines)
|
||||
end += strlen(end) + 1; /* prior to the current line, save contents */
|
||||
|
||||
simplelist_line_pos = end - simplelist_buffer;
|
||||
simplelist_line_remaining = sizeof(simplelist_buffer) - simplelist_line_pos;
|
||||
simplelist_line_count = lines;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue