From 054d17fafb7a5e3a570c868a77de4d4a331010da Mon Sep 17 00:00:00 2001 From: cgd Date: Wed, 9 Feb 1994 00:06:07 +0000 Subject: [PATCH] patch from Diomidis Spinellis to fix 'infinite' loop --- usr.bin/sed/process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index bf8c5c0560d7..6ad0c0715dc6 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -37,7 +37,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)process.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: process.c,v 1.9 1994/02/03 23:44:57 cgd Exp $"; +static char *rcsid = "$Id: process.c,v 1.10 1994/02/09 00:06:07 cgd Exp $"; #endif /* not lint */ #include @@ -348,7 +348,8 @@ substitute(cp) /* Move past this match. */ s += match[0].rm_eo; slen -= match[0].rm_eo; - } while(regexec_e(re, s, REG_NOTBOL, 0, slen)); + } while(match[0].rm_so != match[0].rm_eo && + regexec_e(re, s, REG_NOTBOL, 0, slen)); /* Copy trailing retained string. */ cspace(&SS, s, slen, APPEND); break;