Fix http://bugs.busybox.net/view.php?id=826 in which "(echo; echo) | sed x"
authorRob Landley <rob@landley.net>
Wed, 28 Jun 2006 13:50:59 +0000 (13:50 -0000)
committerRob Landley <rob@landley.net>
Wed, 28 Jun 2006 13:50:59 +0000 (13:50 -0000)
crashes because the empty state of the hold space is NULL but the empty
state of the pattern space is "".

editors/sed.c

index 219a44008bc982cd141607ca2692baaeb0f611b2..ed584e5dfeb76ef01359932d624520756980099e 100644 (file)
@@ -1054,7 +1054,7 @@ restart:
                                        case 'x': /* Exchange hold and pattern space */
                                        {
                                                char *tmp = pattern_space;
-                                               pattern_space = bbg.hold_space;
+                                               pattern_space = bbg.hold_space ? : xzalloc(1);
                                                no_newline=0;
                                                bbg.hold_space = tmp;
                                                break;