diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index bf92f2c07460..602ddb01333e 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);