In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/49b3432a7438e964c8fc187b40c147293b929233?hp=33f1827ffcb11ab760b1c6b1f0fc240a00058c4b>

- Log -----------------------------------------------------------------
commit 49b3432a7438e964c8fc187b40c147293b929233
Author: David Mitchell <[email protected]>
Date:   Wed Dec 28 14:05:43 2016 +0000

    Allow sv = &PL_sv_undef; sv_set_undef(sv) to work
    
    RT #130385
    
    Technically
    
        sv = &PL_sv_undef;
        ....
        sv_set_undef(sv)
    
    is modifying a read-only variable and so should croak, but some XS code
    relies on the behaviour previous to the introduction of sv_set_undef(),
    where:
    
        sv = &PL_sv_undef;
        ....
        sv_setsv(sv, &PL_undef)
    
    silently succeeds (sv_setsv() returns immediately if src and dst
    addresses are the same).
-----------------------------------------------------------------------

Summary of changes:
 sv.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sv.c b/sv.c
index e3026f7d33..83d82fc721 100644
--- a/sv.c
+++ b/sv.c
@@ -4808,8 +4808,13 @@ Perl_sv_set_undef(pTHX_ SV *sv)
 
     if (type <= SVt_IV) {
         assert(!SvGMAGICAL(sv));
-        if (SvREADONLY(sv))
+        if (SvREADONLY(sv)) {
+            /* does undeffing PL_sv_undef count as modifying a read-only
+             * variable? Some XS code does this */
+            if (sv == &PL_sv_undef)
+                return;
             Perl_croak_no_modify();
+        }
 
         if (SvROK(sv)) {
             if (SvWEAKREF(sv))

--
Perl5 Master Repository

Reply via email to