fix tty crashes for empty news file
- menu-window code could access a null pointer when there was no data - menu-window code can't handle empty contents, because there's no place to position the cursor, so force text mode - still looked ugly, so added a check to avoid displaying anything if the file was empty
This commit is contained in:
@@ -1243,8 +1243,10 @@ struct WinDesc *cw;
|
|||||||
if (cw->npages > 1)
|
if (cw->npages > 1)
|
||||||
Sprintf(cw->morestr, "(%d of %d)",
|
Sprintf(cw->morestr, "(%d of %d)",
|
||||||
curr_page + 1, (int) cw->npages);
|
curr_page + 1, (int) cw->npages);
|
||||||
else
|
else if (msave)
|
||||||
Strcpy(cw->morestr, msave);
|
Strcpy(cw->morestr, msave);
|
||||||
|
else
|
||||||
|
Strcpy(cw->morestr, defmorestr);
|
||||||
|
|
||||||
tty_curs(window, 1, page_lines);
|
tty_curs(window, 1, page_lines);
|
||||||
cl_end();
|
cl_end();
|
||||||
@@ -1517,7 +1519,7 @@ tty_display_nhwindow(window, blocking)
|
|||||||
} else
|
} else
|
||||||
tty_clear_nhwindow(WIN_MESSAGE);
|
tty_clear_nhwindow(WIN_MESSAGE);
|
||||||
|
|
||||||
if (cw->data)
|
if (cw->data || !cw->maxrow)
|
||||||
process_text_window(window, cw);
|
process_text_window(window, cw);
|
||||||
else
|
else
|
||||||
process_menu_window(window, cw);
|
process_menu_window(window, cw);
|
||||||
@@ -1910,6 +1912,8 @@ boolean complain;
|
|||||||
} else if(u.ux) docrt();
|
} else if(u.ux) docrt();
|
||||||
} else {
|
} else {
|
||||||
winid datawin = tty_create_nhwindow(NHW_TEXT);
|
winid datawin = tty_create_nhwindow(NHW_TEXT);
|
||||||
|
boolean empty = TRUE;
|
||||||
|
|
||||||
if(complain
|
if(complain
|
||||||
#ifndef NO_TERMS
|
#ifndef NO_TERMS
|
||||||
&& nh_CD
|
&& nh_CD
|
||||||
@@ -1926,11 +1930,12 @@ boolean complain;
|
|||||||
if ((cr = index(buf, '\r')) != 0) *cr = 0;
|
if ((cr = index(buf, '\r')) != 0) *cr = 0;
|
||||||
#endif
|
#endif
|
||||||
if (index(buf, '\t') != 0) (void) tabexpand(buf);
|
if (index(buf, '\t') != 0) (void) tabexpand(buf);
|
||||||
|
empty = FALSE;
|
||||||
tty_putstr(datawin, 0, buf);
|
tty_putstr(datawin, 0, buf);
|
||||||
if(wins[datawin]->flags & WIN_CANCELLED)
|
if(wins[datawin]->flags & WIN_CANCELLED)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tty_display_nhwindow(datawin, FALSE);
|
if (!empty) tty_display_nhwindow(datawin, FALSE);
|
||||||
tty_destroy_nhwindow(datawin);
|
tty_destroy_nhwindow(datawin);
|
||||||
(void) dlb_fclose(f);
|
(void) dlb_fclose(f);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user