On Thu, Jun 15, 2017 at 09:01:15AM +0200, Otto Moerbeek wrote:

at last a followup, for the original problem.

This diff incorporates your later comment. It does not cause the newly
added regress test to fail, though.

So that poses the question if this is what you meant.

        -Otto

Index: process.c
===================================================================
RCS file: /cvs/src/usr.bin/sed/process.c,v
retrieving revision 1.32
diff -u -p -r1.32 process.c
--- process.c   22 Feb 2017 14:09:09 -0000      1.32
+++ process.c   27 Jun 2017 09:16:33 -0000
@@ -120,8 +120,10 @@ redirect:
                                cp = cp->u.c;
                                goto redirect;
                        case 'c':
+                               if (pd)
+                                       break;
                                pd = 1;
-                               psl = 0;
+                               ps[psl = 0] = '\0';
                                if (cp->a2 == NULL || lastaddr || lastline())
                                        (void)fprintf(outfile, "%s", cp->t);
                                break;
@@ -138,6 +140,7 @@ redirect:
                                } else {
                                        psl -= (p + 1) - ps;
                                        memmove(ps, p + 1, psl);
+                                       ps[psl] = '\0';
                                        goto top;
                                }
                        case 'g':

Reply via email to