From 6e882b43b6242e102f4514904c57abb68ad69efe Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 12 Jan 2014 12:12:13 +0100 Subject: 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 --- apps/gui/line.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'apps/gui/line.c') 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) { -- cgit v1.2.3