[Libreoffice-commits] core.git: include/basegfx

Caolán McNamara caolanm at redhat.com
Mon Oct 9 12:59:31 UTC 2017


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

New commits:
commit dbd9ad421534b7bad6324f0c2a358416c80b4d81
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Oct 9 10:03:03 2017 +0100

    ofz+ubsan: limit double range to sal_Int32 limits
    
    wmf fuzzing
    
    Change-Id: I37b437717f064c6c85cd383315adf4e989486412
    Reviewed-on: https://gerrit.libreoffice.org/43272
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/basegfx/numeric/ftools.hxx b/include/basegfx/numeric/ftools.hxx
index 35a1a35111b2..19d8d1722aff 100644
--- a/include/basegfx/numeric/ftools.hxx
+++ b/include/basegfx/numeric/ftools.hxx
@@ -22,7 +22,7 @@
 
 #include <rtl/math.hxx>
 #include <basegfx/basegfxdllapi.h>
-
+#include <limits>
 
 // standard PI defines from solar.h, but we do not want to link against tools
 
@@ -59,6 +59,10 @@ namespace basegfx
     */
     inline sal_Int32 fround( double fVal )
     {
+        if (fVal >= std::numeric_limits<sal_Int32>::max())
+            return std::numeric_limits<sal_Int32>::max();
+        else if (fVal <= std::numeric_limits<sal_Int32>::min())
+            return std::numeric_limits<sal_Int32>::min();
         return fVal > 0.0 ? static_cast<sal_Int32>( fVal + .5 ) : -static_cast<sal_Int32>( -fVal + .5 );
     }
 


More information about the Libreoffice-commits mailing list