diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index b8c8f49163c9..9c09efae6fa6 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -674,6 +674,8 @@ sopno lev; /* PLUS nesting level */ return(NULL); assert(m->pmatch[i].rm_so != -1); len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; + if (len == 0) + return(NULL); assert(stop - m->beginp >= len); if (sp > stop - len) return(NULL); /* not enough left to match */