summaryrefslogtreecommitdiff
path: root/include/basegfx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-09 10:03:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-10-09 14:59:09 +0200
commitdbd9ad421534b7bad6324f0c2a358416c80b4d81 (patch)
tree2e7d5a26b7de2276ae3eec052917c3bc0a15e835 /include/basegfx
parent5fcfa368d8a4aa3156674fe38365f57218a6952e (diff)
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@libreoffice.org> 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.hxx6
1 files changed, 5 insertions, 1 deletions
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 );
}