From: Nicholas Clark Date: Sun, 19 Feb 2006 18:57:35 +0000 (+0000) Subject: To make arithmetic on tainted dualvars work properly requires that X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0aa395f8d7800f582dd6179dfa4fb15674fdc9d2;p=p5sagit%2Fp5-mst-13.2.git To make arithmetic on tainted dualvars work properly requires that sv_2nv uses SvIVX in preference to SvPVX, if SVp_IOK is true. p4raw-id: //depot/perl@27228 --- diff --git a/sv.c b/sv.c index bbdeb99..966b1d7 100644 --- a/sv.c +++ b/sv.c @@ -2257,7 +2257,7 @@ Perl_sv_2nv(pTHX_ register SV *sv) mg_get(sv); if (SvNOKp(sv)) return SvNVX(sv); - if (SvPOKp(sv) && SvLEN(sv)) { + if ((SvPOKp(sv) && SvLEN(sv)) && !SvIOKp(sv)) { if (!SvIOKp(sv) && ckWARN(WARN_NUMERIC) && !grok_number(SvPVX_const(sv), SvCUR(sv), NULL)) not_a_number(sv); diff --git a/t/op/taint.t b/t/op/taint.t index b544262..76b553b 100755 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -17,7 +17,7 @@ use Config; use File::Spec::Functions; BEGIN { require './test.pl'; } -plan tests => 245; +plan tests => 246; $| = 1; @@ -1148,3 +1148,13 @@ TERNARY_CONDITIONALS: { } cmp_ok $i, '<', 10000, "infinite m//g"; } + +SKIP: +{ + my $got_dualvar; + eval 'use Scalar::Util "dualvar"; $got_dualvar++'; + skip "No Scalar::Util::dualvar" unless $got_dualvar; + my $a = Scalar::Util::dualvar(3, $^X); + my $b = $a + 5; + is ($b, 8, "Arithmetic on tainted dualvars works"); +}