From 55a8c269d2e77f798f9ca55d7a4afb7a9f98a701 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 26 Dec 2015 18:42:14 +0100 Subject: Extra checks --- src/sc_editor.c | 6 ++++++ src/shape.c | 2 ++ src/wrap.c | 6 ++++++ 3 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/sc_editor.c b/src/sc_editor.c index 463e090..4c0e58a 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -852,6 +852,12 @@ static void insert_text(char *t, SCEditor *e) sbx = e->cursor_box; sps = e->cursor_pos; sbox = &e->cursor_frame->lines[sln].boxes[sbx]; + + if ( sbox->type == WRAP_BOX_NOTHING ) { + printf("Upgrading nothing box to Pango box\n"); + return; + } + sseg = which_segment(sbox, sps, &err); if ( err ) return; diff --git a/src/shape.c b/src/shape.c index 84f8f03..08ca8d1 100644 --- a/src/shape.c +++ b/src/shape.c @@ -114,6 +114,8 @@ static void add_nothing_box(struct wrap_line *line, SCBlock *scblock, box->height = sc_interp_get_height(scin); box->filename = NULL; box->editable = editable; + box->segs = NULL; + box->n_segs = 0; line->n_boxes++; } diff --git a/src/wrap.c b/src/wrap.c index c4ce531..fa383b3 100644 --- a/src/wrap.c +++ b/src/wrap.c @@ -126,6 +126,12 @@ int which_segment(struct wrap_box *box, int pos, int *err) int i = 0; int ch = 0; + if ( box->type != WRAP_BOX_PANGO ) { + fprintf(stderr, "which_segment() called on wrong box type.\n"); + *err = 1; + return 0; + } + do { if ( ch + box->segs[i].len_chars >= pos ) break; ch += box->segs[i++].len_chars; -- cgit v1.2.3