diff options
author | Denys Vlasenko | 2016-08-16 15:09:40 +0200 |
---|---|---|
committer | Denys Vlasenko | 2016-08-16 15:09:40 +0200 |
commit | 252559601f12e22ad3a687fb8188fdbf63bbdc45 (patch) | |
tree | 534d9090163e81f88a1f561150683aa6860daa13 | |
parent | 560cf8c7ebd3feff6244a381a300cb2bac8570ec (diff) | |
download | busybox-252559601f12e22ad3a687fb8188fdbf63bbdc45.zip busybox-252559601f12e22ad3a687fb8188fdbf63bbdc45.tar.gz |
less: fix SEGV
testcase: echo "" | less, then press ')' key
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/less.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/miscutils/less.c b/miscutils/less.c index d7076db..10e1d8e 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -1591,7 +1591,9 @@ static void match_right_bracket(char bracket) { unsigned i; - if (strchr(flines[cur_fline], bracket) == NULL) { + if (cur_fline >= max_fline + || strchr(flines[cur_fline], bracket) == NULL + ) { print_statusline("No bracket in top line"); return; } @@ -1609,7 +1611,9 @@ static void match_left_bracket(char bracket) { int i; - if (strchr(flines[cur_fline + max_displayed_line], bracket) == NULL) { + if (cur_fline + max_displayed_line >= max_fline + || strchr(flines[cur_fline + max_displayed_line], bracket) == NULL + ) { print_statusline("No bracket in bottom line"); return; } |