From 584ff995faa629c82377d3a44fb25d5100d09c76 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 29 Apr 2019 23:27:44 +0200 Subject: Trap possible error case --- libstorycode/gtk/gtkslideview.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libstorycode/gtk/gtkslideview.c b/libstorycode/gtk/gtkslideview.c index 240b348..0990a6f 100644 --- a/libstorycode/gtk/gtkslideview.c +++ b/libstorycode/gtk/gtkslideview.c @@ -196,6 +196,8 @@ static int get_cursor_pos(SlideItem *item, Stylesheet *stylesheet, PangoRectangle rect; double padl, padr, padt, padb; + if ( item->paras == NULL ) return 1; + if ( item->paras[cpos.para].layout == NULL ) { fprintf(stderr, "get_cursor_pos: No layout\n"); return 1; @@ -550,6 +552,14 @@ static int find_cursor(SlideItem *item, Stylesheet *stylesheet, x -= padl; y -= padt; + if ( item->paras == NULL ) { + printf("No paragraphs (item %p)!\n", item); + pos->para = 0; + pos->pos = 0; + pos->trail = 0; + return 0; + } + do { PangoRectangle rect; pango_layout_get_extents(item->paras[i++].layout, NULL, &rect); -- cgit v1.2.3