summaryrefslogtreecommitdiff
path: root/src/fe-text
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2018-03-17 13:36:38 +0100
committerailin-nemui <ailin-nemui@users.noreply.github.com>2018-03-17 13:36:38 +0100
commitc7ca8102c002287f492ca71f2193ee9b269f5bf5 (patch)
tree15fcc96c0697bf9754fba51b77fe1a4309c763a1 /src/fe-text
parent65a139aa9e8a7cb7a7a123ab57ee05836c9e89ea (diff)
downloadirssi-c7ca8102c002287f492ca71f2193ee9b269f5bf5.zip
fix a crash when trying to append to a NULL line
reported by @vague666
Diffstat (limited to 'src/fe-text')
-rw-r--r--src/fe-text/gui-printtext.c7
-rw-r--r--src/fe-text/textbuffer-view.c5
2 files changed, 11 insertions, 1 deletions
diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c
index 13d8c233..83a36f14 100644
--- a/src/fe-text/gui-printtext.c
+++ b/src/fe-text/gui-printtext.c
@@ -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;
diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c
index 99625ecc..3ccd95f5 100644
--- a/src/fe-text/textbuffer-view.c
+++ b/src/fe-text/textbuffer-view.c
@@ -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);