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

ofz#3797 Integer-overflow

Change-Id: Iff545f441f2cf5e4f7626a6deff0ee0136c3af6b
Reviewed-on: https://gerrit.libreoffice.org/43829Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst d271ec87
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define INCLUDED_TOOLS_HELPERS_HXX #define INCLUDED_TOOLS_HELPERS_HXX
#include <sal/config.h> #include <sal/config.h>
#include <sal/types.h>
#include <cassert> #include <cassert>
#include <type_traits> #include <type_traits>
...@@ -40,9 +41,13 @@ MinMax(T nVal, long nMin, long nMax) ...@@ -40,9 +41,13 @@ MinMax(T nVal, long nMin, long nMax)
: nMin); : nMin);
} }
inline long AlignedWidth4Bytes( long nWidthBits ) inline sal_uInt32 AlignedWidth4Bytes(sal_uInt32 nWidthBits)
{ {
return ( ( nWidthBits + 31 ) >> 5 ) << 2; if (nWidthBits > SAL_MAX_UINT32 - 31)
nWidthBits = SAL_MAX_UINT32;
else
nWidthBits += 31;
return (nWidthBits >> 5) << 2;
} }
inline long FRound( double fVal ) inline long FRound( double fVal )
......
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