소스 검색

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);
 	}