From: Denys Vlasenko Date: Tue, 16 Aug 2016 13:09:40 +0000 (+0200) Subject: less: fix SEGV X-Git-Tag: 1_26_0~301 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=252559601f12e22ad3a687fb8188fdbf63bbdc45;p=oweals%2Fbusybox.git less: fix SEGV testcase: echo "" | less, then press ')' key Signed-off-by: Denys Vlasenko --- diff --git a/miscutils/less.c b/miscutils/less.c index d7076dbbc..10e1d8e16 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; }