This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: A surprising segfault
authorSADAHIRO Tomoyuki <BQW10602@nifty.com>
Sat, 5 Nov 2005 05:54:00 +0000 (05:54 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 5 Nov 2005 10:10:09 +0000 (10:10 +0000)
Message-Id: <20051105135053.27D7.BQW10602@nifty.com>

p4raw-id: //depot/perl@26011

pp.c
pp_sort.c
pp_sys.c

diff --git a/pp.c b/pp.c
index eb217d0..63bc8ed 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -700,7 +700,7 @@ PP(pp_chop)
     while (MARK < SP)
        do_chop(TARG, *++MARK);
     SP = ORIGMARK;
-    PUSHTARG;
+    XPUSHTARG;
     RETURN;
 }
 
@@ -718,7 +718,7 @@ PP(pp_chomp)
 
     while (SP > MARK)
        count += do_chomp(POPs);
-    PUSHi(count);
+    XPUSHi(count);
     RETURN;
 }
 
index 68ad610..245426e 100644 (file)
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1504,6 +1504,7 @@ PP(pp_sort)
 
     if (gimme != G_ARRAY) {
        SP = MARK;
+       EXTEND(SP,1);
        RETPUSHUNDEF;
     }
 
index c6eb020..5c1ebd2 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -430,12 +430,16 @@ PP(pp_warn)
     SV *tmpsv;
     const char *tmps;
     STRLEN len;
-    if (SP - MARK != 1) {
+    if (SP - MARK > 1) {
        dTARGET;
        do_join(TARG, &PL_sv_no, MARK, SP);
        tmpsv = TARG;
        SP = MARK + 1;
     }
+    else if (SP == MARK) {
+       tmpsv = &PL_sv_no;
+       EXTEND(SP, 1);
+    }
     else {
        tmpsv = TOPs;
     }
@@ -3402,7 +3406,7 @@ PP(pp_chown)
     const I32 value = (I32)apply(PL_op->op_type, MARK, SP);
 
     SP = MARK;
-    PUSHi(value);
+    XPUSHi(value);
     RETURN;
 }
 
@@ -3993,7 +3997,7 @@ PP(pp_system)
            if (errno != EAGAIN) {
                value = -1;
                SP = ORIGMARK;
-               PUSHi(value);
+               XPUSHi(value);
                if (did_pipes) {
                    PerlLIO_close(pp[0]);
                    PerlLIO_close(pp[1]);
@@ -4042,7 +4046,7 @@ PP(pp_system)
                    STATUS_NATIVE_CHILD_SET(-1);
                }
            }
-           PUSHi(STATUS_CURRENT);
+           XPUSHi(STATUS_CURRENT);
            RETURN;
        }
        if (did_pipes) {
@@ -4088,7 +4092,7 @@ PP(pp_system)
     STATUS_NATIVE_CHILD_SET(value);
     do_execfree();
     SP = ORIGMARK;
-    PUSHi(result ? value : STATUS_CURRENT);
+    XPUSHi(result ? value : STATUS_CURRENT);
 #endif /* !FORK or VMS */
     RETURN;
 }
@@ -4140,7 +4144,7 @@ PP(pp_exec)
     }
 
     SP = ORIGMARK;
-    PUSHi(value);
+    XPUSHi(value);
     RETURN;
 }