Skip to content

Commit b20d572

Browse files
tomsommerdveeden
authored andcommitted
Fix type conversions
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. Fixes #78, #312 Credit kentnl-gentoo@b6b8540
1 parent 6d8687b commit b20d572

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

dbdimp.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4448,8 +4448,7 @@ dbd_st_fetch(SV *sth, imp_sth_t* imp_sth)
44484448
if (!(fields[i].flags & ZEROFILL_FLAG))
44494449
{
44504450
/* Coerce to double and set scalar as NV */
4451-
(void) SvNV(sv);
4452-
SvNOK_only(sv);
4451+
sv_setnv(sv, SvNV(sv));
44534452
}
44544453
break;
44554454

@@ -4460,13 +4459,11 @@ dbd_st_fetch(SV *sth, imp_sth_t* imp_sth)
44604459
/* Coerce to integer and set scalar as UV resp. IV */
44614460
if (fields[i].flags & UNSIGNED_FLAG)
44624461
{
4463-
(void) SvUV(sv);
4464-
SvIOK_only_UV(sv);
4462+
sv_setuv(sv, SvUV(sv));
44654463
}
44664464
else
44674465
{
4468-
(void) SvIV(sv);
4469-
SvIOK_only(sv);
4466+
sv_setiv(sv, SvIV(sv));
44704467
}
44714468
}
44724469
break;

0 commit comments

Comments
 (0)