summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-25 10:22:00 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-10-25 21:34:18 +0200
commitd754330e05ba2d81fb263f569bddf3e537b8054c (patch)
tree531e6384351e9a1d868efda9b1140d1fd10bf4fc /sal
parent713fb4a8d3a19440013ca423f048ff6431c11d14 (diff)
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>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index a9404871c228..997280784351 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -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;