From: Nicholas Clark Date: Tue, 15 Jun 2004 07:17:17 +0000 (+0000) Subject: Assert SvTYPE is at least PGMV whenever accessing SvSTASH X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2649f2c19a9dc4cac2cf535de25fe7b36dee8328;p=p5sagit%2Fp5-mst-13.2.git Assert SvTYPE is at least PGMV whenever accessing SvSTASH p4raw-id: //depot/perl@22935 --- diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs index 2efc07c..a8cd003 100644 --- a/ext/Storable/Storable.xs +++ b/ext/Storable/Storable.xs @@ -4287,9 +4287,8 @@ static SV *retrieve_ref(pTHX_ stcxt_t *cxt, char *cname) */ if (cname) { - /* Do not use sv_upgrade to preserve STASH */ - SvFLAGS(rv) &= ~SVTYPEMASK; - SvFLAGS(rv) |= SVt_RV; + /* No need to do anything, as rv will already be PVMG. */ + assert (SvTYPE(rv) >= SVt_RV); } else { sv_upgrade(rv, SVt_RV); } diff --git a/sv.h b/sv.h index bc03bb8..229690c 100644 --- a/sv.h +++ b/sv.h @@ -742,7 +742,7 @@ and leaves the UTF-8 status as it was. #ifdef DEBUGGING #define SvMAGIC(sv) ((assert(SvTYPE(sv) >= SVt_PVMG)), ((XPVMG*) SvANY(sv))->xmg_magic) -#define SvSTASH(sv) ((XPVMG*) SvANY(sv))->xmg_stash +#define SvSTASH(sv) ((assert(SvTYPE(sv) >= SVt_PVMG)), (XPVMG*) SvANY(sv))->xmg_stash #else #define SvMAGIC(sv) ((XPVMG*) SvANY(sv))->xmg_magic #define SvSTASH(sv) ((XPVMG*) SvANY(sv))->xmg_stash