--- Devel-FindRef/FindRef.xs 2008/04/27 05:59:06 1.8 +++ Devel-FindRef/FindRef.xs 2008/07/11 15:29:48 1.9 @@ -12,6 +12,10 @@ # define SVt_LAST 16 #endif +#if !PERL_VERSION_ATLEAST (5,10,0) +# define SvPAD_OUR(dummy) 0 +#endif + #define res_pair(text) \ do { \ AV *av = newAV (); \ @@ -48,7 +52,8 @@ PPCODE: { SV *arena, *targ; - int rmagical, i; + U32 rmagical; + int i; AV *about = newAV (); AV *excl = newAV (); @@ -76,16 +81,21 @@ if (SvTYPE (sv) >= SVt_PVMG) { - MAGIC *mg = SvMAGIC (sv); - while (mg) + + if (SvTYPE (sv) != SVt_PVMG || SvPAD_OUR (sv)) { - if (mg->mg_obj == targ) - res_pair (form ("referenced (in mg_obj) by '%c' type magic attached to", mg->mg_type)); + MAGIC *mg = SvMAGIC (sv); + + while (mg) + { + if (mg->mg_obj == targ) + res_pair (form ("referenced (in mg_obj) by '%c' type magic attached to", mg->mg_type)); - if ((SV *)mg->mg_ptr == targ && mg->mg_flags & MGf_REFCOUNTED) - res_pair (form ("referenced (in mg_ptr) by '%c' type magic attached to", mg->mg_type)); + if ((SV *)mg->mg_ptr == targ && mg->mg_flags & MGf_REFCOUNTED) + res_pair (form ("referenced (in mg_ptr) by '%c' type magic attached to", mg->mg_type)); - mg = mg->mg_moremagic; + mg = mg->mg_moremagic; + } } }