summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-01-03 16:25:19 +0000
committerStephan Bergmann <sbergman@redhat.com>2018-01-04 15:31:06 +0100
commitf042128907598e5f82e759a175b564a68edfb490 (patch)
treee8d4f894b8f43289a6b1876f56a069ff9a30204b /sal
parent10d642580d1fa2eb3450a0323c9f1338b170ccee (diff)
ofz#4886 Integer-overflow
sal/rtl/math.cxx:1106:29: runtime error: signed integer overflow: 15 - -2147483648 cannot be represented in type 'int' Change-Id: Ia81eca9da1fe7cc1a5c5319742b32bd742fb817e Reviewed-on: https://gerrit.libreoffice.org/47329 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 96c5843dcfea..a450f7baa774 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -1103,12 +1103,14 @@ double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
else
nExp = 0;
- int nIndex = 15 - nExp;
+ int nIndex;
- if ( nIndex > 15 )
+ if (nExp < 0)
nIndex = 15;
- else if ( nIndex <= 1 )
+ else if (nExp >= 14)
nIndex = 0;
+ else
+ nIndex = 15 - nExp;
fValue = floor(fValue + 0.5 + nKorrVal[nIndex]);
}