From 8e2f75b833b447b74f8b5c5c987c67e1cccfd43a Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Fri, 9 Nov 2001 10:17:44 +0000 Subject: [PATCH] The algorithm that computes the tables used in the BM search algorithm sometimes access an array beyond it's length. This only happens in the last iteration of a loop, and the value fetched is not used then, so the bug is a relatively innocent one. Fix this by not fetching any value on the last iteration of said loop. Submitted by: MKI MFC after: 1 week --- lib/libc/regex/regcomp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index bf92f2c0746..602ddb01333 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -2045,7 +2045,8 @@ struct re_guts *g; g->mlen + ssuffix - suffix); suffix++; } - ssuffix = pmatches[ssuffix]; + if (suffix < g->mlen) + ssuffix = pmatches[ssuffix]; } free(pmatches);