From: Gerard Goossen Date: Mon, 2 Nov 2009 09:32:31 +0000 (+0100) Subject: Check to see if there was a body which needs freeing using the old_type instead of... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc78644842f1135350b5fc2a51984c02385a59fe;p=p5sagit%2Fp5-mst-13.2.git Check to see if there was a body which needs freeing using the old_type instead of the arena flag, which is not set with PURIFY --- diff --git a/sv.c b/sv.c index a85966b..4b97e58 100644 --- a/sv.c +++ b/sv.c @@ -1456,14 +1456,14 @@ Perl_sv_upgrade(pTHX_ register SV *const sv, svtype new_type) (unsigned long)new_type); } - if (old_type_details->arena) { - /* If there was an old body, then we need to free it. - Note that there is an assumption that all bodies of types that - can be upgraded came from arenas. Only the more complex non- - upgradable types are allowed to be directly malloc()ed. */ + if (old_type > SVt_IV) { /* SVt_IVs are overloaded for PTEs */ #ifdef PURIFY my_safefree(old_body); #else + /* Note that there is an assumption that all bodies of types that + can be upgraded came from arenas. Only the more complex non- + upgradable types are allowed to be directly malloc()ed. */ + assert(old_type_details->arena); del_body((void*)((char*)old_body + old_type_details->offset), &PL_body_roots[old_type]); #endif