In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/4c347e8605390be7efd8c5c530639eeaa097864e?hp=f318c24d5fe0afd05d6f929510f6e068ea7f7fc7>

- Log -----------------------------------------------------------------
commit 4c347e8605390be7efd8c5c530639eeaa097864e
Author: Father Chrysostomos <[email protected]>
Date:   Wed Dec 5 09:35:36 2012 -0800

    regen pod issue
    
    I don’t see how I could have made the number of potential errors
    go down, but that’s what podcheck.t insists on saying, even after
    I re-ren autodoc.pl to make sure.

M       t/porting/known_pod_issues.dat

commit bd047b2c46c84dde15e7333abb2ecb4a248079d0
Author: Father Chrysostomos <[email protected]>
Date:   Wed Dec 5 06:09:42 2012 -0800

    sv.c: Correct newSVpvn_share docs
    
    something I overlooked

M       sv.c

commit 235fc0448781935a0881cec712da57f29b35d9a9
Author: Father Chrysostomos <[email protected]>
Date:   Wed Dec 5 06:07:51 2012 -0800

    sv.h: Warning about cows in SvPV_set apidocs

M       sv.h

commit 14ca8ff4550183227342256bd45185f428ac400d
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 23:13:56 2012 -0800

    Stop "\N{...}" from leaking after errors
    
    After a syntax error, S_new_constant in toke.c was not mortalising as
    promised.
    
    In this case, it doesn’t need to mortalise the variable.  It can sim-
    ply free it.

M       t/op/svleak.t
M       toke.c

commit 2f995715b99bbbe6f6e89b02b509a1f99f41ecd4
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 22:09:29 2012 -0800

    Use SvREFCNT_dec_NN in various cop.h macros
    
    Many of these SVs are never null, and therefore need no null checks.

M       cop.h

commit ecabb0047526b110411e1e4dd94c18088bb2566a
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 22:05:09 2012 -0800

    Stop v111111111111111 from leaking under fatal warnings
    
    Actually, you need more digits than that to get a leak.
    
    This commit arranges for the SV passed to scan_vstring to be freed
    in case scan_vstring triggers an integer overflow warning when fatal
    warnings are enabled.

M       t/op/svleak.t
M       toke.c

commit 615e0a48731ea26b42cfaf932fb88fd71387df37
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 21:59:07 2012 -0800

    toke.c apidocs: Note that scan_vstring might croak

M       toke.c
-----------------------------------------------------------------------

Summary of changes:
 cop.h                          |   13 +++++++------
 sv.c                           |    3 ++-
 sv.h                           |    7 ++++++-
 t/op/svleak.t                  |    5 ++---
 t/porting/known_pod_issues.dat |    4 ++--
 toke.c                         |   16 ++++++++++++++--
 6 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/cop.h b/cop.h
index 74ec151..0a682f1 100644
--- a/cop.h
+++ b/cop.h
@@ -653,7 +653,7 @@ struct block_format {
            /* abandon @_ if it got reified */                          \
            if (AvREAL(cx->blk_sub.argarray)) {                         \
                const SSize_t fill = AvFILLp(cx->blk_sub.argarray);     \
-               SvREFCNT_dec(cx->blk_sub.argarray);                     \
+               SvREFCNT_dec_NN(cx->blk_sub.argarray);                  \
                cx->blk_sub.argarray = newAV();                         \
                av_extend(cx->blk_sub.argarray, fill);                  \
                AvREIFY_only(cx->blk_sub.argarray);                     \
@@ -677,8 +677,9 @@ struct block_format {
 #define POPFORMAT(cx)                                                  \
        setdefout(cx->blk_format.dfoutgv);                              \
        CvDEPTH(cx->blk_format.cv)--;                                   \
-       if (!CvDEPTH(cx->blk_format.cv)) SvREFCNT_dec(cx->blk_format.cv); \
-       SvREFCNT_dec(cx->blk_format.dfoutgv);
+       if (!CvDEPTH(cx->blk_format.cv))                                \
+           SvREFCNT_dec_NN(cx->blk_format.cv);                         \
+       SvREFCNT_dec_NN(cx->blk_format.dfoutgv);
 
 /* eval context */
 struct block_eval {
@@ -717,7 +718,7 @@ struct block_eval {
        optype = CxOLD_OP_TYPE(cx);                                     \
        PL_eval_root = cx->blk_eval.old_eval_root;                      \
        if (cx->blk_eval.cur_text && SvSCREAM(cx->blk_eval.cur_text))   \
-           SvREFCNT_dec(cx->blk_eval.cur_text);                        \
+           SvREFCNT_dec_NN(cx->blk_eval.cur_text);                     \
        if (cx->blk_eval.old_namesv)                                    \
            sv_2mortal(cx->blk_eval.old_namesv);                        \
     } STMT_END
@@ -783,8 +784,8 @@ struct block_loop {
 
 #define POPLOOP(cx)                                                    \
        if (CxTYPE(cx) == CXt_LOOP_LAZYSV) {                            \
-           SvREFCNT_dec(cx->blk_loop.state_u.lazysv.cur);              \
-           SvREFCNT_dec(cx->blk_loop.state_u.lazysv.end);              \
+           SvREFCNT_dec_NN(cx->blk_loop.state_u.lazysv.cur);           \
+           SvREFCNT_dec_NN(cx->blk_loop.state_u.lazysv.end);           \
        }                                                               \
        if (CxTYPE(cx) == CXt_LOOP_FOR)                                 \
            SvREFCNT_dec(cx->blk_loop.state_u.ary.ary);
diff --git a/sv.c b/sv.c
index 72d41ca..8bc60db 100644
--- a/sv.c
+++ b/sv.c
@@ -8613,7 +8613,8 @@ Perl_newSVhek(pTHX_ const HEK *const hek)
 
 Creates a new SV with its SvPVX_const pointing to a shared string in the string
 table.  If the string does not already exist in the table, it is
-created first.  Turns on READONLY and FAKE.  If the C<hash> parameter
+created first.  Turns on the SvIsCOW flag (or READONLY
+and FAKE in 5.16 and earlier).  If the C<hash> parameter
 is non-zero, that value is used; otherwise the hash is computed.
 The string's hash can later be retrieved from the SV
 with the C<SvSHARED_HASH()> macro.  The idea here is
diff --git a/sv.h b/sv.h
index 2576a65..bea0a2f 100644
--- a/sv.h
+++ b/sv.h
@@ -757,7 +757,12 @@ C<SvIV_set> instead of the lvalue assignment to C<SvIVX>.
 Set the value of the NV pointer in sv to val.  See C<SvIV_set>.
 
 =for apidoc Am|void|SvPV_set|SV* sv|char* val
-Set the value of the PV pointer in sv to val.  See C<SvIV_set>.
+Set the value of the PV pointer in sv to val.  See also C<SvIV_set>.
+
+Beware that the existing pointer may be involved in copy-on-write or other
+mischief, so do C<SvOOK_off(sv)> and use C<sv_force_normal> or
+C<SvPV_force> (or check the SvIsCOW flag) first to make sure this
+modification is safe.
 
 =for apidoc Am|void|SvUV_set|SV* sv|UV val
 Set the value of the UV pointer in sv to val.  See C<SvIV_set>.
diff --git a/t/op/svleak.t b/t/op/svleak.t
index 475baed..75067b1 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -15,7 +15,7 @@ BEGIN {
 
 use Config;
 
-plan tests => 107;
+plan tests => 108;
 
 # run some code N times. If the number of SVs at the end of loop N is
 # greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -103,10 +103,8 @@ eleak(2, 0, "$all /(?{})+/ ", '(?{})+ with fatal 
warnings');
 eleak(2, 0, "$all /[\\i]/ ", 'invalid charclass escape with fatal warns');
 eleak(2, 0, "$all /[:foo:]/ ", '/[:foo:]/ with fatal warnings');
 eleak(2, 0, "$all /[a-\\d]/ ", '[a-\d] char class with fatal warnings');
-$::TODO = 'still leaks';
 eleak(2, 0, "$all v111111111111111111111111111111111111111111111111",
      'vstring num overflow with fatal warnings');
-undef $::TODO;
 
 eleak(2, 0, 'sub{<*>}');
 
@@ -272,6 +270,7 @@ eleak(2, 0, 'no warnings; 2 2;BEGIN{}',
 }
 eleak(2, 0, "\"\$\0\356\"", 'qq containing $ <null> something');
 eleak(2, 0, 'END OF TERMS AND CONDITIONS', 'END followed by words');
+eleak(2, 0, "+ + +;qq|\\N{a}|"x10,'qq"\N{a}" after errors');
 eleak(2, 0, "qq|\\c|;"x10,     '"too many errors" from qq"\c"');
 $::TODO = 'still leaks';
 eleak(2, 0, "qq|\\N{%}|"x10,   '"too many errors" from qq"\N{%}"');
diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat
index 0242ce3..6e006fc 100644
--- a/t/porting/known_pod_issues.dat
+++ b/t/porting/known_pod_issues.dat
@@ -1,4 +1,4 @@
-# This file is the data file for porting/podcheck.t.
+# This file is the data file for t/porting/podcheck.t.
 # There are three types of lines.
 # Comment lines are white-space only or begin with a '#', like this one.  Any
 #   changes you make to the comment lines will be lost when the file is
@@ -210,7 +210,7 @@ os2/os2/os2-rexx/dll/dll.pm Verbatim line length including 
indents exceeds 79 by
 os2/os2/os2-rexx/rexx.pm       Verbatim line length including indents exceeds 
79 by    1
 pod/perl.pod   Verbatim line length including indents exceeds 79 by    8
 pod/perlaix.pod        Verbatim line length including indents exceeds 79 by    
11
-pod/perlapi.pod        ? Should you be using L<...> instead of 77
+pod/perlapi.pod        ? Should you be using L<...> instead of 76
 pod/perlapi.pod        Verbatim line length including indents exceeds 79 by    
6
 pod/perlapi.pod        unresolved internal link        3
 pod/perlapio.pod       Verbatim line length including indents exceeds 79 by    
5
diff --git a/toke.c b/toke.c
index b60d720..86bb994 100644
--- a/toke.c
+++ b/toke.c
@@ -9011,7 +9011,7 @@ S_checkcomma(pTHX_ const char *s, const char *name, const 
char *what)
     }
 }
 
-/* Either returns sv, or mortalizes sv and returns a new SV*.
+/* Either returns sv, or mortalizes/frees sv and returns a new SV*.
    Best used as sv=new_constant(..., sv, ...).
    If s, pv are NULL, calls subroutine with one argument,
    and <type> is used with error messages only.
@@ -9033,7 +9033,10 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const 
char *key, STRLEN keylen,
 
     /* charnames doesn't work well if there have been errors found */
     if (PL_error_count > 0 && strEQ(key,"charnames"))
+    {
+       SvREFCNT_dec_NN(sv);
        return &PL_sv_undef;
+    }
 
     if (!table
        || ! (PL_hints & HINT_LOCALIZE_HH)
@@ -10987,7 +10990,11 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
     case 'v':
 vstring:
                sv = newSV(5); /* preallocate storage space */
+               ENTER_with_name("scan_vstring");
+               SAVEFREESV(sv);
                s = scan_vstring(s, PL_bufend, sv);
+               SvREFCNT_inc_simple_void_NN(sv);
+               LEAVE_with_name("scan_vstring");
        break;
     }
 
@@ -11537,13 +11544,18 @@ vstring, as well as updating the passed in sv.
 
 Function must be called like
 
-       sv = newSV(5);
+       sv = sv_2mortal(newSV(5));
        s = scan_vstring(s,e,sv);
 
 where s and e are the start and end of the string.
 The sv should already be large enough to store the vstring
 passed in, for performance reasons.
 
+This function may croak if fatal warnings are enabled in the
+calling scope, hence the sv_2mortal in the example (to prevent
+a leak).  Make sure to do SvREFCNT_inc afterwards if you use
+sv_2mortal.
+
 */
 
 char *

--
Perl5 Master Repository

Reply via email to