ofz#3789 Integer-overflow

with input 69e9223372036854775807

Change-Id: Iaf5a85170d144be2db5604340d784a8982754e08
Reviewed-on: https://gerrit.libreoffice.org/43815
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2017-10-25 10:22:00 +01:00
parent 713fb4a8d3
commit d754330e05

View File

@@ -19,6 +19,7 @@
#include <rtl/math.h>
#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <rtl/alloc.h>
#include <rtl/character.hxx>
@@ -938,7 +939,9 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
if ( bExpSign )
nExp = -nExp;
long nAllExp = ( bOverflow ? 0 : nExp + nValExp );
long nAllExp(0);
if (!bOverflow)
bOverflow = o3tl::checked_add(nExp, nValExp, nAllExp);
if ( nAllExp > DBL_MAX_10_EXP || (bOverflow && !bExpSign) )
{ // overflow
fVal = HUGE_VAL;