sc/inc/patattr.hxx              |    2 +-
 sc/source/core/data/patattr.cxx |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit eb1ec67d4e3f1992d7f31d824f06e48df8429540
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Jun 7 11:25:21 2023 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Jun 7 13:33:06 2023 +0200

    Avoid signed integer overflow
    
    For whatever reason e5fe8434110c1299527a0d03bf450e1b6d08ca57 "use a SIMD
    friendly hashcode for ScPatternAttr" had changed ScPatternAttr::mxHashCode 
from
    sizt_t to sal_Int32, better use unsigned sal_uInt32 to avoid
    
    > /sc/source/core/data/patattr.cxx:1444:17: runtime error: signed integer 
overflow: 31 * 887503681 cannot be represented in type 'int'
    
    during e.g. CppunitTest_chart2_geometry
    (<https://ci.libreoffice.org//job/lo_ubsan/2802/>)
    
    Change-Id: Ia561b245431d812f43586013477208426aa1cc11
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152697
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 067193136fb9..49cae62994b4 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -53,7 +53,7 @@ enum ScAutoFontColorMode
 class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem
 {
     std::optional<OUString>  pName;
-    mutable std::optional<sal_Int32> mxHashCode;
+    mutable std::optional<sal_uInt32> mxHashCode;
     ScStyleSheet*              pStyle;
     sal_uInt64                 mnKey;
 public:
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index d2be666aa349..2b347365f0c2 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1435,10 +1435,10 @@ void ScPatternAttr::CalcHashCode() const
     // This is an unrolled hash function so the compiler/CPU can execute it in 
parallel,
     // because we hit this hard when loading documents with lots of styles.
     // Set up seed so that an empty pattern does not have an (invalid) hash of 
0.
-    sal_Int32 h1 = 1;
-    sal_Int32 h2 = 1;
-    sal_Int32 h3 = 1;
-    sal_Int32 h4 = 1;
+    sal_uInt32 h1 = 1;
+    sal_uInt32 h2 = 1;
+    sal_uInt32 h3 = 1;
+    sal_uInt32 h4 = 1;
     for (auto it = rSet.GetItems_Impl(), end = rSet.GetItems_Impl() + 
(compareSize / 4 * 4); it != end; )
     {
         h1 = 31 * h1 + reinterpret_cast<size_t>(*it);

Reply via email to