From: Nicholas Clark Date: Fri, 17 Jun 2005 13:42:03 +0000 (+0000) Subject: The only way is up! X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f5282e155fe851218634336979bf8171277ed014;p=p5sagit%2Fp5-mst-13.2.git The only way is up! (*up*grades. Or croak) p4raw-id: //depot/perl@24885 --- diff --git a/sv.c b/sv.c index afa5382..09d6b16 100644 --- a/sv.c +++ b/sv.c @@ -1341,6 +1341,9 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 mt) if (SvTYPE(sv) == mt) return; + if (SvTYPE(sv) > mt) + croak ("sv_upgrade from type %d down to type %d", SvTYPE(sv), mt); + pv = NULL; cur = 0; len = 0; @@ -6881,7 +6884,7 @@ Perl_sv_inc(pTHX_ register SV *sv) if (!(flags & SVp_POK) || !*SvPVX_const(sv)) { if ((flags & SVTYPEMASK) < SVt_PVIV) - sv_upgrade(sv, SVt_IV); + sv_upgrade(sv, ((flags & SVTYPEMASK) > SVt_IV ? SVt_PVIV : SVt_IV)); (void)SvIOK_only(sv); SvIV_set(sv, 1); return;