This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow sv = &PL_sv_undef; sv_set_undef(sv) to work
[perl5.git] / sv.c
diff --git a/sv.c b/sv.c
index e3026f7..83d82fc 100644 (file)
--- 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))