瀏覽代碼

Don't segfault when scrolling down with empty scrollback

Jochen Sprickerhof 5 年之前
父節點
當前提交
faf0800f0b
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      scroll.c

+ 1 - 1
scroll.c

@@ -276,7 +276,7 @@ scrolldown(char *buf, size_t size)
 	int rows = ws.ws_row;
 
 	/* print one page */
-	for (; rows > 0 && TAILQ_PREV(bottom, tailhead, entries) != NULL; rows--) {
+	for (; rows > 0 && bottom != NULL && TAILQ_PREV(bottom, tailhead, entries) != NULL; rows--) {
 		bottom = TAILQ_PREV(bottom, tailhead, entries);
 		write(STDOUT_FILENO, bottom->buf, bottom->size);
 	}