Avoid infinite recursion on:

echo "foo foo bar bar bar baz" | sed 's/\([^ ]*\)\( *\1\)*/\1/g'

Obtained from:	OpenBSD via NetBSD (rev. 1.18)
This commit is contained in:
Xin LI 2007-03-05 03:07:36 +00:00
parent c907770c56
commit 0f4481c5e4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=167216

View File

@ -674,6 +674,8 @@ sopno lev; /* PLUS nesting level */
return(NULL); return(NULL);
assert(m->pmatch[i].rm_so != -1); assert(m->pmatch[i].rm_so != -1);
len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
if (len == 0)
return(NULL);
assert(stop - m->beginp >= len); assert(stop - m->beginp >= len);
if (sp > stop - len) if (sp > stop - len)
return(NULL); /* not enough left to match */ return(NULL); /* not enough left to match */