From feb059e8cff5fd1057faf88caa127623e35775d2 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 15 Feb 2016 18:59:23 +0100 Subject: Fix segmentation fault on reload with pre-load hook We need to manually force a reinitialization of the todo item list box before reloading the items. Otherwise, the list box contains dangling references to the linked list of todo items which has already been cleared at this point. After the pre-load hook is called, the windows are redrawn by wins_unprepare_external() and these invalid references are accessed, leading to a segmentation fault. Signed-off-by: Lukas Fleischer --- src/io.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/io.c b/src/io.c index f9e98ae..e0a8502 100644 --- a/src/io.c +++ b/src/io.c @@ -857,6 +857,14 @@ void io_reload_data(void) recur_event_llist_init(); todo_init_list(); + /* + * Temporarily reinitialize the todo list box without any items to make + * sure wins_unprepare_external() does not fail when it is called after + * executing the pre-load hook. + */ + ui_todo_load_items(); + ui_todo_sel_reset(); + io_load_data(NULL); io_unset_modified(); ui_todo_load_items(); -- cgit v1.2.3-54-g00ecf