summaryrefslogtreecommitdiffstats
path: root/apps/gui/line.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-01-12 12:12:13 +0100
committerThomas Martitz <kugel@rockbox.org>2014-01-12 12:12:13 +0100
commit6e882b43b6242e102f4514904c57abb68ad69efe (patch)
tree95debb7268e98342f42f9c7c281562b16446c7f0 /apps/gui/line.c
parentc0a02c98c169e11fb4770e096cd1dd2e56b97f4d (diff)
downloadrockbox-6e882b43b6242e102f4514904c57abb68ad69efe.tar.gz
rockbox-6e882b43b6242e102f4514904c57abb68ad69efe.tar.bz2
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.c12
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
const char *text, bool prevent_scroll, int text_skip_pixels);
struct line_desc_scroll {
- struct line_desc desc; /* must be first! */
+ struct line_desc desc;
bool used;
-} lines[MAX_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 */
+static struct line_desc_scroll lines[MAX_LINES+1];
static struct line_desc_scroll *get_line_desc(void)
{