diff options
author | Thomas Martitz <kugel@rockbox.org> | 2014-01-12 12:12:13 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-01-12 12:12:13 +0100 |
commit | 6e882b43b6242e102f4514904c57abb68ad69efe (patch) | |
tree | 95debb7268e98342f42f9c7c281562b16446c7f0 /apps/gui/line.c | |
parent | c0a02c98c169e11fb4770e096cd1dd2e56b97f4d (diff) | |
download | rockbox-6e882b43b6242e102f4514904c57abb68ad69efe.tar.gz rockbox-6e882b43b6242e102f4514904c57abb68ad69efe.zip |
put_line(): Do not lock up if the scroll engine runs out of lines.
Allocate MAX_LINES+1 because at the time get_line_desc() is called
the scroll engine did not yet determine that it ran out of lines
(because puts_scroll_func() wasn't called yet. Therefore we can
run out of lines before setting the used field. By allocating
one item more we can survive that point and set used to false
if the scroll engine runs out of lines.
Change-Id: I7a9af1bce256c6e07d254f096bd5865fa7cf2cee
Diffstat (limited to 'apps/gui/line.c')
-rw-r--r-- | apps/gui/line.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/gui/line.c b/apps/gui/line.c index fe017970e6..fd35102ab0 100644 --- a/apps/gui/line.c +++ b/apps/gui/line.c | |||
@@ -51,9 +51,17 @@ static void put_text(struct screen *display, int x, int y, struct line_desc *lin | |||
51 | const char *text, bool prevent_scroll, int text_skip_pixels); | 51 | const char *text, bool prevent_scroll, int text_skip_pixels); |
52 | 52 | ||
53 | struct line_desc_scroll { | 53 | struct line_desc_scroll { |
54 | struct line_desc desc; /* must be first! */ | 54 | struct line_desc desc; |
55 | bool used; | 55 | bool used; |
56 | } lines[MAX_LINES]; | 56 | }; |
57 | |||
58 | /* Allocate MAX_LINES+1 because at the time get_line_desc() is called | ||
59 | * the scroll engine did not yet determine that it ran out of lines | ||
60 | * (because puts_scroll_func() wasn't called yet. Therefore we can | ||
61 | * run out of lines before setting the used field. By allocating | ||
62 | * one item more we can survive that point and set used to false | ||
63 | * if the scroll engine runs out of lines */ | ||
64 | static struct line_desc_scroll lines[MAX_LINES+1]; | ||
57 | 65 | ||
58 | static struct line_desc_scroll *get_line_desc(void) | 66 | static struct line_desc_scroll *get_line_desc(void) |
59 | { | 67 | { |