Commit Diff


commit - 69e1c12a07cad69482c2e445348a4d07e30033ce
commit + b471d6700229aeffa6e61ddda52e572057337211
blob - 9ce480ab9621f92565caa28207ccc60fd3861816
blob + 02bc69712b041bfec75c628922b9315b3d025d6a
--- cmd.c
+++ cmd.c
@@ -170,6 +170,9 @@ cmd_scroll_line_up(struct buffer *buffer)
 {
 	struct vline	*vl;
 
+	if (buffer->top_line == NULL)
+		return;
+
 	if ((vl = TAILQ_PREV(buffer->top_line, vhead, vlines))
 	    == NULL)
 		return;
@@ -195,6 +198,9 @@ cmd_scroll_up(struct buffer *buffer)
 	struct vline	*vl;
 	int		 i;
 
+	if (buffer->top_line == NULL)
+		return;
+
 	for (i = 0; i < body_lines; ++i) {
 		vl = TAILQ_PREV(buffer->top_line, vhead, vlines);
 		if (vl == NULL)
@@ -209,6 +215,9 @@ void
 cmd_scroll_down(struct buffer *buffer)
 {
 	int i;
+
+	if (buffer->top_line == NULL)
+		return;
 
 	for (i = 0; i < body_lines; ++i) {
 		if (!forward_line(buffer, +1))