1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #862 from ailin-nemui/line_is_null

fix a crash when trying to append to a NULL line
This commit is contained in:
ailin-nemui 2018-03-26 12:46:04 +02:00 committed by GitHub
commit 7fc59d2d10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 15 deletions

View File

@ -120,12 +120,19 @@ void gui_printtext_internal(int xpos, int ypos, const char *str)
next_xpos = next_ypos = -1;
}
static void view_add_eol(TEXT_BUFFER_VIEW_REC *view, LINE_REC **line);
void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str, time_t time)
{
GUI_WINDOW_REC *gui;
gui = WINDOW_GUI(dest->window);
if (prev == NULL && !gui->view->buffer->last_eol) {
/* we have an unfinished line in the buffer still */
view_add_eol(gui->view, &gui->insert_after);
}
gui->use_insert_after = TRUE;
gui->insert_after = prev;
gui->insert_after_time = time;
@ -249,22 +256,8 @@ static void view_add_eol(TEXT_BUFFER_VIEW_REC *view, LINE_REC **line)
textbuffer_view_insert_line(view, *line);
}
static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
void *bgcolor, void *pflags,
char *str, TEXT_DEST_REC *dest)
static void print_text_no_window(int flags, int fg, int bg, int attr, const char *str)
{
GUI_WINDOW_REC *gui;
TEXT_BUFFER_VIEW_REC *view;
LINE_REC *insert_after;
LINE_INFO_REC lineinfo;
int fg, bg, flags, attr;
flags = GPOINTER_TO_INT(pflags);
fg = GPOINTER_TO_INT(fgcolor);
bg = GPOINTER_TO_INT(bgcolor);
get_colors(flags, &fg, &bg, &attr);
if (window == NULL) {
g_return_if_fail(next_xpos != -1);
term_set_color2(root_window, attr, fg, bg);
@ -278,6 +271,25 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
}
}
next_xpos += term_addstr(root_window, str);
}
static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
void *bgcolor, void *pflags,
const char *str, TEXT_DEST_REC *dest)
{
GUI_WINDOW_REC *gui;
TEXT_BUFFER_VIEW_REC *view;
LINE_REC *insert_after;
LINE_INFO_REC lineinfo;
int fg, bg, flags, attr;
flags = GPOINTER_TO_INT(pflags);
fg = GPOINTER_TO_INT(fgcolor);
bg = GPOINTER_TO_INT(bgcolor);
get_colors(flags, &fg, &bg, &attr);
if (window == NULL) {
print_text_no_window(flags, fg, bg, attr, str);
return;
}

View File

@ -913,11 +913,14 @@ void textbuffer_view_resize(TEXT_BUFFER_VIEW_REC *view, int width, int height)
} else if (view->startline == view->bottom_startline &&
view->subline > view->bottom_subline) {
view->subline = view->bottom_subline;
} else {
} else if (view->startline != NULL) {
/* make sure the subline is still in allowed range */
linecount = view_get_linecount(view, view->startline);
if (view->subline > linecount)
view->subline = linecount;
} else {
/* we don't have a startline. still under construction? */
view->subline = 0;
}
textbuffer_view_init_ypos(view);