diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2014-05-06 12:50:55 -0400 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2014-05-29 16:50:54 +1000 |
commit | c174bf3bd0aaba83d7aba81b0fbcb0055109a168 (patch) | |
tree | 6fba75fe6f73d7fcd9d6a7f5b87cb423dde3449c | |
parent | 00b25eff1415ab27d5829f30fea1fecd57a7934e (diff) | |
download | perl-c174bf3bd0aaba83d7aba81b0fbcb0055109a168.tar.gz |
Quad_t and Uquad_t cannot unpack as NVs.
If IVSIZE >= 8, a Quad_t is always >= IV_MIN, and <= IV_MAX, and an
Uquad_t is always (>= 0 aka UV_MIN and) <= UV_MAX; they cannot escape
their quadness and be NVs. (This logic may fail if Quad_t is not 8
bytes, but then other things would no doubt fail.)
Also tighten the logic by adding HAS_QUAD, also for the pack case.
Fix for Coverity perl5 CID 28942.
-rw-r--r-- | pp_pack.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -1632,14 +1632,13 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c PUSHs(newSVpvn_flags(aptr, len, SVs_TEMP)); } break; -#if IVSIZE >= 8 +#if defined(HAS_QUAD) && IVSIZE >= 8 case 'q': while (len-- > 0) { Quad_t aquad; SHIFT_VAR(utf8, s, strend, aquad, datumtype, needs_swap); if (!checksum) - mPUSHs(aquad >= IV_MIN && aquad <= IV_MAX ? - newSViv((IV)aquad) : newSVnv((NV)aquad)); + mPUSHs(newSViv((IV)aquad)); else if (checksum > bits_in_uv) cdouble += (NV)aquad; else @@ -1651,8 +1650,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c Uquad_t auquad; SHIFT_VAR(utf8, s, strend, auquad, datumtype, needs_swap); if (!checksum) - mPUSHs(auquad <= UV_MAX ? - newSVuv((UV)auquad) : newSVnv((NV)auquad)); + mPUSHs(newSVuv((UV)auquad)); else if (checksum > bits_in_uv) cdouble += (NV)auquad; else @@ -2982,7 +2980,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) PUSH32(utf8, cur, &ai32, needs_swap); } break; -#if IVSIZE >= 8 +#if defined(HAS_QUAD) && IVSIZE >= 8 case 'Q': while (len-- > 0) { Uquad_t auquad; |