From 2e6c5a5c8f749206747a97acc3de4170449b2ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 14 Jan 2015 11:28:55 +0100 Subject: Fix segfault when using arrow keys in prompt --- editor.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/editor.c b/editor.c index e472351..d0b281b 100644 --- a/editor.c +++ b/editor.c @@ -138,13 +138,13 @@ bool editor_window_split(EditorWin *original) { void editor_window_jumplist_add(EditorWin *win, size_t pos) { Mark mark = text_mark_set(win->text, pos); - if (mark) + if (mark && win->jumplist) ringbuf_add(win->jumplist, mark); } size_t editor_window_jumplist_prev(EditorWin *win) { size_t cur = window_cursor_get(win->win); - for (;;) { + while (win->jumplist) { Mark mark = ringbuf_prev(win->jumplist); if (!mark) return cur; @@ -157,7 +157,7 @@ size_t editor_window_jumplist_prev(EditorWin *win) { size_t editor_window_jumplist_next(EditorWin *win) { size_t cur = window_cursor_get(win->win); - for (;;) { + while (win->jumplist) { Mark mark = ringbuf_next(win->jumplist); if (!mark) return cur; @@ -169,7 +169,8 @@ size_t editor_window_jumplist_next(EditorWin *win) { } void editor_window_jumplist_invalidate(EditorWin *win) { - ringbuf_invalidate(win->jumplist); + if (win->jumplist) + ringbuf_invalidate(win->jumplist); } size_t editor_window_changelist_prev(EditorWin *win) { @@ -367,7 +368,7 @@ static EditorWin *editor_window_new_text(Editor *ed, Text *text) { win->win = window_new(win->text); win->statuswin = newwin(1, ed->width, 0, 0); win->jumplist = ringbuf_alloc(31); - if (!win->win || !win->statuswin || !win->jumplist) { + if (!win->win || !win->statuswin) { editor_window_free(ed, win); return NULL; } -- cgit v1.2.3