Skip to content

Commit

Permalink
Fix type conversions
Browse files Browse the repository at this point in the history
Calling SvNV() for magical scalar is not enough for float type conversion.
It caused problem for Amavis in tainted mode -- all float values were zero.
On the other hand SvIV() and SvUV() seems to work fine. To be sure that
correct value of float is in scalar use sv_setnv() with explicit NV float
value. Similar code is changed also for integers IV/UV.

This patch should fix reported Amavis bug:
perl5-dbi#78

See also reported perl bug about SvNV():
https://rt.perl.org/Public/Bug/Display.html?id=130801
  • Loading branch information
pali committed Feb 24, 2017
1 parent 26f6e14 commit fb5f7f9
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions dbdimp.c
Expand Up @@ -4547,8 +4547,7 @@ dbd_st_fetch(SV *sth, imp_sth_t* imp_sth)
if (!(fields[i].flags & ZEROFILL_FLAG))
{
/* Coerce to dobule and set scalar as NV */
(void) SvNV(sv);
SvNOK_only(sv);
sv_setnv(sv, SvNV(sv));
}
break;

Expand All @@ -4557,15 +4556,9 @@ dbd_st_fetch(SV *sth, imp_sth_t* imp_sth)
{
/* Coerce to integer and set scalar as UV resp. IV */
if (fields[i].flags & UNSIGNED_FLAG)
{
(void) SvUV(sv);
SvIOK_only_UV(sv);
}
sv_setuv(sv, SvUV(sv));
else
{
(void) SvIV(sv);
SvIOK_only(sv);
}
sv_setiv(sv, SvIV(sv));
}
break;

Expand Down

0 comments on commit fb5f7f9

Please sign in to comment.