From 773d404ee2b99797763012a32b317422ac18d64e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 26 Apr 2021 05:09:57 -0500 Subject: Bugfix: sed s command couldn't skip initial match. --- toys/posix/sed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toys') diff --git a/toys/posix/sed.c b/toys/posix/sed.c index 9bd05034..d5a4a833 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -443,7 +443,7 @@ static void sed_line(char **pline, long plen) // If we're replacing only a specific match, skip if this isn't it off = command->sflags>>4; if (off && off != ++count) { - memcpy(l2+l2used, rline, match[0].rm_eo); + if (l2) memcpy(l2+l2used, rline, match[0].rm_eo); l2used += match[0].rm_eo; rline += match[0].rm_eo; -- cgit v1.2.3