foxygit / doom Log in
commit 0b27583c5cdfecd020cdaf7dcce140e186c3b4ff
Author:     Jonathan Dowland <jon+github@alcopop.org>
AuthorDate: Wed Jul 22 07:02:41 2015 +0100
Commit:     Jonathan Dowland <jon+github@alcopop.org>
CommitDate: Wed Jul 22 10:08:16 2015 +0100

    Add constraint check to CellOverflowedSize

    Fixes #585.
---
 textscreen/txt_table.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/textscreen/txt_table.c b/textscreen/txt_table.c
index 5913d4de..28c882e3 100644
--- a/textscreen/txt_table.c
+++ b/textscreen/txt_table.c
@@ -99,7 +99,14 @@ static void CellOverflowedSize(txt_table_t *table, int x, int y,
         // Every overflow cell must point to either (x, y) or another
         // overflow cell. This means the first in every row must be
         // txt_table_overflow_down.
+
+        if (y1 * table->columns + x >= table->num_widgets)
+        {
+            break;
+        }
+
         widget = table->widgets[y1 * table->columns + x];
+
         if (y1 != y && widget != &txt_table_overflow_down)
         {
             break;