diff --git a/terminal.c b/terminal.c index f4902fef..d2ca8a48 100644 --- a/terminal.c +++ b/terminal.c @@ -1045,6 +1045,27 @@ static int sblines(Terminal *term) return sblines; } +static void null_line_error(Terminal *term, int y, int lineno, + tree234 *whichtree, int treeindex, + const char *varname) +{ + extern const char commitid[]; /* in version.c */ + modalfatalbox("%s==NULL in terminal.c\n" + "lineno=%d y=%d w=%d h=%d\n" + "count(scrollback=%p)=%d\n" + "count(screen=%p)=%d\n" + "count(alt=%p)=%d alt_sblines=%d\n" + "whichtree=%p treeindex=%d\n" + "commitid=%s\n\n" + "Please contact " + "and pass on the above information.", + varname, lineno, y, term->cols, term->rows, + term->scrollback, count234(term->scrollback), + term->screen, count234(term->screen), + term->alt_screen, count234(term->alt_screen), + term->alt_sblines, whichtree, treeindex, commitid); +} + /* * Retrieve a line of the screen or of the scrollback, according to * whether the y coordinate is non-negative or negative @@ -1079,29 +1100,16 @@ static termline *lineptr(Terminal *term, int y, int lineno, int screen) } if (whichtree == term->scrollback) { unsigned char *cline = index234(whichtree, treeindex); + if (!cline) + null_line_error(term, y, lineno, whichtree, treeindex, "cline"); line = decompressline(cline, NULL); } else { line = index234(whichtree, treeindex); } /* We assume that we don't screw up and retrieve something out of range. */ - if (line == NULL) { - extern const char commitid[]; /* in version.c */ - modalfatalbox("line==NULL in terminal.c\n" - "lineno=%d y=%d w=%d h=%d\n" - "count(scrollback=%p)=%d\n" - "count(screen=%p)=%d\n" - "count(alt=%p)=%d alt_sblines=%d\n" - "whichtree=%p treeindex=%d\n" - "commitid=%s\n\n" - "Please contact " - "and pass on the above information.", - lineno, y, term->cols, term->rows, - term->scrollback, count234(term->scrollback), - term->screen, count234(term->screen), - term->alt_screen, count234(term->alt_screen), - term->alt_sblines, whichtree, treeindex, commitid); - } + if (line == NULL) + null_line_error(term, y, lineno, whichtree, treeindex, "line"); assert(line != NULL); /*