diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-10-29 13:13:37 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-10-29 21:24:41 +0100 |
commit | 4ee4c599a33e4f7c80046a16894674202692b4b4 (patch) | |
tree | f95d402166f118f19854b0b201dc13306f410c07 /include/basegfx | |
parent | 6e4fc0508909af407e595d17b06a6b1d1cb36ba0 (diff) |
ofz#3883 Integer-overflow
Change-Id: Ie1fd6617d6e598c6e2cfa8a83a0ffe16948e1efd
Reviewed-on: https://gerrit.libreoffice.org/44022
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/basegfx')
-rw-r--r-- | include/basegfx/numeric/ftools.hxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/basegfx/numeric/ftools.hxx b/include/basegfx/numeric/ftools.hxx index 19d8d1722aff..19e8e101987c 100644 --- a/include/basegfx/numeric/ftools.hxx +++ b/include/basegfx/numeric/ftools.hxx @@ -59,11 +59,11 @@ namespace basegfx */ inline sal_Int32 fround( double fVal ) { - if (fVal >= std::numeric_limits<sal_Int32>::max()) + if (fVal >= std::numeric_limits<sal_Int32>::max() - .5) return std::numeric_limits<sal_Int32>::max(); - else if (fVal <= std::numeric_limits<sal_Int32>::min()) + else if (fVal <= std::numeric_limits<sal_Int32>::min() + .5) return std::numeric_limits<sal_Int32>::min(); - return fVal > 0.0 ? static_cast<sal_Int32>( fVal + .5 ) : -static_cast<sal_Int32>( -fVal + .5 ); + return fVal > 0.0 ? static_cast<sal_Int32>( fVal + .5 ) : static_cast<sal_Int32>( fVal - .5 ); } /** Round double to nearest integer |