Skip to content

Commit

Permalink
Merge pull request #1 from tokuhirom/blead-fix
Browse files Browse the repository at this point in the history
Need to call `Gv_AMG()` before call mg_find()
  • Loading branch information
gfx committed Apr 3, 2013
2 parents e4062ef + e787079 commit 89a7265
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions DataUtil.xs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,21 @@ my_check_type_primitive(pTHX_ SV* const sv, const my_type_t t){
static bool
my_has_amagic_converter(pTHX_ SV* const sv, const my_type_t t){
const AMT* amt;
const HV *stash;
int o = 0;

if(!SvAMAGIC(sv)) return FALSE;

amt = (AMT*)mg_find((SV*)SvSTASH(SvRV(sv)), PERL_MAGIC_overload_table)->mg_ptr;
if (
(!SvAMAGIC(sv))
|| (!(stash = SvSTASH(SvRV(sv))))
|| (!Gv_AMG((HV*)stash))
) {
return FALSE;
}
amt = (AMT*)mg_find((SV*)stash, PERL_MAGIC_overload_table)->mg_ptr;
assert(amt);
assert(AMT_AMAGIC(amt));


switch(t){
case T_SV:
o = to_sv_amg;
Expand Down Expand Up @@ -220,6 +227,7 @@ my_check_type(pTHX_ SV* const sv, const my_type_t t){
return SvRXOK(sv);
}
else{
SvGETMAGIC(sv);
return my_has_amagic_converter(aTHX_ sv, t);
}
}
Expand Down

0 comments on commit 89a7265

Please sign in to comment.