From 238b27b30e66cbca6d4615d2e20bf4a279a86f89 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 26 Dec 2007 18:53:48 +0000 Subject: [PATCH] Tweak Perl_sv_upgrade() so that references can upgrade to SVt_PV rather than something bigger. Fix a possible bug - "reference" to SVt_NV needs to go direct to SVt_PVNV. p4raw-id: //depot/perl@32738 --- sv.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sv.c b/sv.c index 577c134..17cc281 100644 --- a/sv.c +++ b/sv.c @@ -1095,6 +1095,9 @@ S_new_body(pTHX_ svtype sv_type) #endif +static const struct body_details fake_rv = + { 0, 0, 0, SVt_IV, FALSE, NONV, NOARENA, 0 }; + /* =for apidoc sv_upgrade @@ -1113,7 +1116,7 @@ Perl_sv_upgrade(pTHX_ register SV *sv, svtype new_type) void* new_body; const svtype old_type = SvTYPE(sv); const struct body_details *new_type_details; - const struct body_details *const old_type_details + const struct body_details *old_type_details = bodies_by_type + old_type; SV *referant = NULL; @@ -1170,11 +1173,9 @@ Perl_sv_upgrade(pTHX_ register SV *sv, svtype new_type) case SVt_IV: if (SvROK(sv)) { referant = SvRV(sv); - if (new_type < SVt_PVIV) { - new_type = SVt_PVIV; - /* FIXME to check SvROK(sv) ? SVt_PV : and fake up - old_body_details */ - } + old_type_details = &fake_rv; + if (new_type == SVt_NV) + new_type = SVt_PVNV; } else { if (new_type < SVt_PVIV) { new_type = (new_type == SVt_NV) -- 2.7.4