[Libreoffice-commits] core.git: sc/source

Stephan Bergmann sbergman at redhat.com
Thu Jul 14 16:42:05 UTC 2016


 sc/source/core/tool/token.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 45813450258ccaed8aa117a50085da6eeae97221
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jul 14 18:41:30 2016 +0200

    Avoid undefined behavior when converting (large) double to size_t
    
    Change-Id: I4cc487a21177efed26a10809dbb6126b504fce6c

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1f72090..f81a34b 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -19,6 +19,7 @@
 
 #include <cstddef>
 #include <cstdio>
+#include <functional>
 
 #include <string.h>
 #include <tools/mempool.hxx>
@@ -1672,7 +1673,7 @@ void ScTokenArray::GenHash()
                 {
                     // Constant value.
                     double fVal = p->GetDouble();
-                    nHash += static_cast<size_t>(fVal);
+                    nHash += std::hash<double>()(fVal);
                 }
                 break;
                 case svString:


More information about the Libreoffice-commits mailing list