Kaydet (Commit) dbd9ad42 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz+ubsan: limit double range to sal_Int32 limits

wmf fuzzing

Change-Id: I37b437717f064c6c85cd383315adf4e989486412
Reviewed-on: https://gerrit.libreoffice.org/43272Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 5fcfa368
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <basegfx/basegfxdllapi.h> #include <basegfx/basegfxdllapi.h>
#include <limits>
// standard PI defines from solar.h, but we do not want to link against tools // standard PI defines from solar.h, but we do not want to link against tools
...@@ -59,6 +59,10 @@ namespace basegfx ...@@ -59,6 +59,10 @@ namespace basegfx
*/ */
inline sal_Int32 fround( double fVal ) 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 ); return fVal > 0.0 ? static_cast<sal_Int32>( fVal + .5 ) : -static_cast<sal_Int32>( -fVal + .5 );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment