From c2b9b6eba83e51d52ed7ed58687dfb34af98e3a1 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Thu, 5 Jun 2003 12:10:19 +0000 Subject: [PATCH] Do not dribble zero bytes into the output, by replacing an obfuscated if whose true and false clauses were equivalent with a check that we are not about to stumble off the end of the line. Reported by: peter Pointy hat to: fanf --- usr.bin/sed/process.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index f7d730d253ec..d0fac865bad8 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -362,10 +362,7 @@ substitute(cp) slen -= match[0].rm_eo; lastempty = 0; } else { - if (match[0].rm_so == 0) - cspace(&SS, s, match[0].rm_so + 1, - APPEND); - else + if (match[0].rm_so < slen) cspace(&SS, s + match[0].rm_so, 1, APPEND); s += match[0].rm_so + 1;