This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bodge to make Tk work - like the UTF8 flag, the READONLY flag has too
[perl5.git] / sv.c
diff --git a/sv.c b/sv.c
index aaf23e3..50501e7 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3941,7 +3941,13 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags)
        return 0;
     if (!SvPOK(sv)) {
        STRLEN len = 0;
-       (void) SvPV_force(sv,len);
+       if (SvREADONLY(sv) && (SvPOKp(sv) || SvIOKp(sv) || SvNOKp(sv))) {
+           (void) sv_2pv_flags(sv,&len, flags);
+           if (SvUTF8(sv))
+               return len;
+       } else {
+           (void) SvPV_force(sv,len);
+       }
     }
 
     if (SvUTF8(sv)) {