include/basegfx/numeric/ftools.hxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 4ee4c599a33e4f7c80046a16894674202692b4b4
Author: Caolán McNamara <[email protected]>
Date:   Sun Oct 29 13:13:37 2017 +0000

    ofz#3883 Integer-overflow
    
    Change-Id: Ie1fd6617d6e598c6e2cfa8a83a0ffe16948e1efd
    Reviewed-on: https://gerrit.libreoffice.org/44022
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>

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
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to