This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Correct the return type for B::MAGIC::MOREMAGIC.
authorNicholas Clark <nick@ccl4.org>
Mon, 1 Nov 2010 17:16:29 +0000 (17:16 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 1 Nov 2010 17:16:29 +0000 (17:16 +0000)
b2adfa9b5e1682df accidentally changed the return type from SV to B::SV.
Clearly there aren't enough tests.
However, the code prior to b2adfa9b5e1682df was buggy (now fixed) in that it
could put a NULL on the perl stack. The stack should only be valid SV pointers.

ext/B/B.xs

index 94b2bc9..b32816c 100644 (file)
@@ -1719,9 +1719,8 @@ MOREMAGIC(mg)
        case 8:
            if (mg->mg_type == PERL_MAGIC_qr) {
                REGEXP *rx = (REGEXP *)mg->mg_obj;
-               PUSHs(make_sv_object(aTHX_ NULL,
-                                    rx ? newSVpvn( RX_PRECOMP(rx), RX_PRELEN(rx))
-                                       : NULL));
+               PUSHs(newSVpvn_flags(rx ? RX_PRECOMP(rx) : NULL,
+                                    rx ? RX_PRELEN(rx) : 0, SVs_TEMP));
            } else {
                croak( "precomp is only meaningful on r-magic" );
            }