From 4ee4c599a33e4f7c80046a16894674202692b4b4 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 29 Oct 2017 13:13:37 +0000 Subject: ofz#3883 Integer-overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie1fd6617d6e598c6e2cfa8a83a0ffe16948e1efd Reviewed-on: https://gerrit.libreoffice.org/44022 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/basegfx/numeric/ftools.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/basegfx') 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::max()) + if (fVal >= std::numeric_limits::max() - .5) return std::numeric_limits::max(); - else if (fVal <= std::numeric_limits::min()) + else if (fVal <= std::numeric_limits::min() + .5) return std::numeric_limits::min(); - return fVal > 0.0 ? static_cast( fVal + .5 ) : -static_cast( -fVal + .5 ); + return fVal > 0.0 ? static_cast( fVal + .5 ) : static_cast( fVal - .5 ); } /** Round double to nearest integer -- cgit