aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-04-29 23:27:44 +0200
committerThomas White <taw@bitwiz.me.uk>2019-04-29 23:27:44 +0200
commit584ff995faa629c82377d3a44fb25d5100d09c76 (patch)
tree11de6892ffee97d64e61880aa3e2785d733b7325
parent4a01f2c889b220cae1d8b31865cde4217d83da36 (diff)
Trap possible error case
-rw-r--r--libstorycode/gtk/gtkslideview.c10
1 files changed, 10 insertions, 0 deletions
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);