Add some warnings
authorThomas White <taw@physics.org>
Wed, 28 Feb 2018 14:08:15 +0000 (15:08 +0100)
committerThomas White <taw@physics.org>
Sat, 3 Mar 2018 16:56:12 +0000 (17:56 +0100)
src/frame.c

index dbe392d..fc2fefc 100644 (file)
@@ -928,6 +928,12 @@ size_t pos_trail_to_offset(Paragraph *para, size_t offs, int trail)
        char *ptr;
 
        nrun = which_run(para, offs);
+
+       if ( nrun == para->n_runs ) {
+               fprintf(stderr, "pos_trail_to_offset: Offset too high\n");
+               return 0;
+       }
+
        run = &para->runs[nrun];
 
        if ( para->type != PARA_TYPE_TEXT ) return 0;
@@ -937,6 +943,11 @@ size_t pos_trail_to_offset(Paragraph *para, size_t offs, int trail)
                return 0;
        }
 
+       if ( run->scblock == NULL ) {
+               fprintf(stderr, "pos_trail_to_offset: SCBlock = NULL?\n");
+               return 0;
+       }
+
        if ( (sc_block_name(run->scblock) != NULL)
          && (strcmp(sc_block_name(run->scblock), "newpara") == 0) )
        {