This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op.c: Abstract common override code
[perl5.git] / mg.c
diff --git a/mg.c b/mg.c
index f88428a..e8d22a3 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1974,7 +1974,8 @@ Perl_magic_setdbline(pTHX_ SV *sv, MAGIC *mg)
 
     /* Use sv_2iv instead of SvIV() as the former generates smaller code, and
        setting/clearing debugger breakpoints is not a hot path.  */
-    svp = av_fetch(GvAV(PL_DBline), sv_2iv(MUTABLE_SV((mg)->mg_ptr)), FALSE);
+    svp = av_fetch(MUTABLE_AV(mg->mg_obj),
+                  sv_2iv(MUTABLE_SV((mg)->mg_ptr)), FALSE);
 
     if (svp && SvIOKp(*svp)) {
        OP * const o = INT2PTR(OP*,SvIVX(*svp));
@@ -2298,7 +2299,14 @@ Perl_defelem_target(pTHX_ SV *sv, MAGIC *mg)
        else if (LvSTARGOFF(sv) >= 0) {
            AV *const av = MUTABLE_AV(LvTARG(sv));
            if (LvSTARGOFF(sv) <= AvFILL(av))
+           {
+             if (SvRMAGICAL(av)) {
+               SV * const * const svp = av_fetch(av, LvSTARGOFF(sv), 0);
+               targ = svp ? *svp : NULL;
+             }
+             else
                targ = AvARRAY(av)[LvSTARGOFF(sv)];
+           }
        }
        if (targ && (targ != &PL_sv_undef)) {
            /* somebody else defined it for us */