This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorNicholas Clark <nick@ccl4.org>
Sun, 18 Sep 2005 11:14:27 +0000 (11:14 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 18 Sep 2005 11:14:27 +0000 (11:14 +0000)
[ 24358]
Subject: [PATCH] uninitialized warnings in regcomp
From: Steven Philip Schubiger <steven@accognoscere.org>
Date: Mon, 2 May 2005 01:14:29 +0200 (CEST)
Message-Id: <200505012314.j41NETLk018737@accognoscere.homeunix.org>

[ 24372]
Subject: [perl #33809] optimize macro dXSARGS
From: Sergey Skvortsov (via RT) <perlbug-followup@perl.org>
Date: 17 Jan 2005 09:02:33 -0000
Message-ID: <rt-3.0.11-33809-105714.16.4209917806492@perl.org>

[ 24402]
avoid accessing a just-freed SV (keep ponie happy)
p4raw-link: @24402 on //depot/perl: 10dc53a8154025af62e262e2eb794f2ba054e8e5
p4raw-link: @24372 on //depot/perl: 557b887a4219c4f375c8d0bd3219fb4da7bbc7ff
p4raw-link: @24358 on //depot/perl: 2af232bd5d3f6bd1ea08b47ef83cc57f75149871

p4raw-id: //depot/maint-5.8/perl@25464
p4raw-integrated: from //depot/perl@24402 'merge in' pad.c (@24365..)
p4raw-integrated: from //depot/perl@24372 'merge in' pod/perlapi.pod
(@24328..) XSUB.h universal.c (@24333..)
p4raw-integrated: from //depot/perl@24358 'edit in' regcomp.c
(@24271..)

XSUB.h
pad.c
pod/perlapi.pod
regcomp.c
universal.c

diff --git a/XSUB.h b/XSUB.h
index 5ccafd3..4c51a6e 100644 (file)
--- a/XSUB.h
+++ b/XSUB.h
@@ -54,6 +54,10 @@ C<xsubpp>.
 Sets up the C<ax> variable.
 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
 
+=for apidoc Ams||dAXMARK
+Sets up the C<ax> variable and stack marker variable C<mark>.
+This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
+
 =for apidoc Ams||dITEMS
 Sets up the C<items> variable.
 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
@@ -84,11 +88,14 @@ handled automatically by C<xsubpp>.
 
 #define dAX I32 ax = MARK - PL_stack_base + 1
 
+#define dAXMARK                                \
+       I32 ax = POPMARK;               \
+       register SV **mark = PL_stack_base + ax++
+
 #define dITEMS I32 items = SP - MARK
 
 #define dXSARGS                                \
-       dSP; dMARK;                     \
-       dAX; dITEMS
+       dSP; dAXMARK; dITEMS
 
 #define dXSTARG SV * targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
                             ? PAD_SV(PL_op->op_targ) : sv_newmortal())
diff --git a/pad.c b/pad.c
index 772a494..9528d84 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -256,14 +256,17 @@ Perl_pad_undef(pTHX_ CV* cv)
                && *SvPVX(namesv) == '&')
            {
                CV * const innercv = (CV*)curpad[ix];
+               U32 inner_rc = SvREFCNT(innercv);
+               assert(inner_rc);
                namepad[ix] = Nullsv;
                SvREFCNT_dec(namesv);
 
                if (SvREFCNT(comppad) < 2) { /* allow for /(?{ sub{} })/  */
                    curpad[ix] = Nullsv;
                    SvREFCNT_dec(innercv);
+                   inner_rc--;
                }
-               if (SvREFCNT(innercv) /* in use, not just a prototype */
+               if (inner_rc /* in use, not just a prototype */
                    && CvOUTSIDE(innercv) == cv)
                {
                    assert(CvWEAKOUTSIDE(innercv));
index 416cba6..4685879 100644 (file)
@@ -5417,6 +5417,16 @@ This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
 =for hackers
 Found in file XSUB.h
 
+=item dAXMARK
+
+Sets up the C<ax> variable and stack marker variable C<mark>.
+This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
+
+               dAXMARK;
+
+=for hackers
+Found in file XSUB.h
+
 =item dITEMS
 
 Sets up the C<items> variable.
index 3af345e..c0a1f62 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -772,7 +772,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                 char *s1 = s0 + STR_LEN(scan) - 1, *s2 = s1 - 4;
                  const char *t0 = "\xcc\x88\xcc\x81";
                  const char *t1 = t0 + 3;
-                
+
                 for (s = s0 + 2;
                      s < s2 && (t = ninstr(s, s1, t0, t1));
                      s = t + 4) {
@@ -1826,11 +1826,11 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
 
     Newz(1304, r->offsets, 2*RExC_size+1, U32); /* MJD 20001228 */
     if (r->offsets) {
-      r->offsets[0] = RExC_size; 
+       r->offsets[0] = RExC_size;
     }
     DEBUG_r(PerlIO_printf(Perl_debug_log, 
-                          "%s %"UVuf" bytes for offset annotations.\n", 
-                          r->offsets ? "Got" : "Couldn't get", 
+                          "%s %"UVuf" bytes for offset annotations.\n",
+                          r->offsets ? "Got" : "Couldn't get",
                           (UV)((2*RExC_size+1) * sizeof(U32))));
 
     RExC_rx = r;
@@ -2306,7 +2306,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp)
                    while (isDIGIT(*RExC_parse))
                        RExC_parse++;
                     ret = reganode(pRExC_state, GROUPP, parno);
-                    
+
                    if ((c = *nextchar(pRExC_state)) != ')')
                        vFAIL("Switch condition not recognized");
                  insert_if:
@@ -2428,7 +2428,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp)
     parse_start = RExC_parse;   /* MJD */
     br = regbranch(pRExC_state, &flags, 1);
     /*     branch_len = (paren != 0); */
-    
+
     if (br == NULL)
        return(NULL);
     if (*RExC_parse == '|') {
@@ -2463,7 +2463,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp)
            RExC_extralen += 2;         /* Account for LONGJMP. */
        nextchar(pRExC_state);
        br = regbranch(pRExC_state, &flags, 0);
-        
+
        if (br == NULL)
            return(NULL);
        regtail(pRExC_state, lastbr, br);               /* BRANCH -> BRANCH. */
@@ -2690,9 +2690,9 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp)
                reginsert(pRExC_state, CURLYX,ret);
                                 /* MJD hk */
                 Set_Node_Offset(ret, parse_start+1);
-                Set_Node_Length(ret, 
+                Set_Node_Length(ret,
                                 op == '{' ? (RExC_parse - parse_start) : 1);
-                
+
                if (!SIZE_ONLY && RExC_extralen)
                    NEXT_OFF(ret) = 3;  /* Go over NOTHING to LONGJMP. */
                regtail(pRExC_state, ret, reg_node(pRExC_state, NOTHING));
@@ -3047,9 +3047,9 @@ tryagain:
                                   (U8)(FOLD ? (LOC ? REFFL : REFF) : REF),
                                   num);
                    *flagp |= HASWIDTH;
-                    
+
                     /* override incorrect value set in reganode MJD */
-                    Set_Node_Offset(ret, parse_start+1); 
+                    Set_Node_Offset(ret, parse_start+1);
                     Set_Node_Cur_Length(ret); /* MJD */
                    RExC_parse--;
                    nextchar(pRExC_state);
index c249403..dc6acd6 100644 (file)
@@ -683,7 +683,7 @@ XS(XS_Internals_hash_seed)
 {
     /* Using dXSARGS would also have dITEM and dSP,
      * which define 2 unused local variables.  */
-    dMARK; dAX;
+    dAXMARK;
     XSRETURN_UV(PERL_HASH_SEED);
 }
 
@@ -691,7 +691,7 @@ XS(XS_Internals_rehash_seed)
 {
     /* Using dXSARGS would also have dITEM and dSP,
      * which define 2 unused local variables.  */
-    dMARK; dAX;
+    dAXMARK;
     XSRETURN_UV(PL_rehash_seed);
 }