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

Caolán McNamara caolanm at redhat.com
Wed Oct 25 19:29:26 UTC 2017


 include/tools/helpers.hxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 06533a4b9d2d249e2e16c6870de9ff29d590bb96
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Oct 25 13:07:33 2017 +0100

    ofz#3797 Integer-overflow
    
    Change-Id: Iff545f441f2cf5e4f7626a6deff0ee0136c3af6b
    Reviewed-on: https://gerrit.libreoffice.org/43829
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/tools/helpers.hxx b/include/tools/helpers.hxx
index 858ec4f7fc50..30064cf93fc6 100644
--- a/include/tools/helpers.hxx
+++ b/include/tools/helpers.hxx
@@ -10,6 +10,7 @@
 #define INCLUDED_TOOLS_HELPERS_HXX
 
 #include <sal/config.h>
+#include <sal/types.h>
 
 #include <cassert>
 #include <type_traits>
@@ -40,9 +41,13 @@ MinMax(T nVal, long nMin, long nMax)
            : 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 )


More information about the Libreoffice-commits mailing list