Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/sed Don't attempt to memmove() if psl (pattern space...



details:   https://anonhg.NetBSD.org/src/rev/f7bd3a0b9bc1
branches:  trunk
changeset: 515488:f7bd3a0b9bc1
user:      atatat <atatat%NetBSD.org@localhost>
date:      Thu Sep 27 05:35:44 2001 +0000

description:
Don't attempt to memmove() if psl (pattern space length) is zero.
Fixes PR bin/14074: Simple expression core dumps sed.

diffstat:

 usr.bin/sed/process.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r af5712d43936 -r f7bd3a0b9bc1 usr.bin/sed/process.c
--- a/usr.bin/sed/process.c     Thu Sep 27 03:24:01 2001 +0000
+++ b/usr.bin/sed/process.c     Thu Sep 27 05:35:44 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process.c,v 1.26 1999/11/09 15:06:36 drochner Exp $    */
+/*     $NetBSD: process.c,v 1.27 2001/09/27 05:35:44 atatat Exp $      */
 
 /*-
  * Copyright (c) 1992 Diomidis Spinellis.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)process.c  8.6 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: process.c,v 1.26 1999/11/09 15:06:36 drochner Exp $");
+__RCSID("$NetBSD: process.c,v 1.27 2001/09/27 05:35:44 atatat Exp $");
 #endif
 #endif /* not lint */
 
@@ -142,11 +142,11 @@
                                if ((p = memchr(ps, '\n', psl - 1)) == NULL) {
                                        pd = 1;
                                        goto new;
-                               } else {
+                               } else if (psl != 0) {
                                        psl -= (p + 1) - ps;
                                        memmove(ps, p + 1, psl);
-                                       goto top;
                                }
+                               goto top;
                        case 'g':
                                cspace(&PS, hs, hsl, REPLACE);
                                break;



Home | Main Index | Thread Index | Old Index