check lower bounds when skipping page down

This commit is contained in:
Marco Kirchner 2016-09-07 19:29:57 +02:00
parent f81c80b2a1
commit 47a6d0b626

4
text.c
View File

@ -317,8 +317,8 @@ int textViewer(char *file) {
} else { // Skip page down
base_pos = base_pos + MAX_ENTRIES;
if (base_pos >= n_lines - MAX_POSITION) {
base_pos = n_lines - MAX_POSITION;
rel_pos = MAX_POSITION - 1;
base_pos = MAX(n_lines - MAX_POSITION, 0);
rel_pos = MIN(MAX_POSITION - 1, n_lines-1);
}
}