Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82218 - trunk/boost/functional/hash/detail
From: thom.heller_at_[hidden]
Date: 2012-12-27 05:49:20


Author: theller
Date: 2012-12-27 05:49:19 EST (Thu, 27 Dec 2012)
New Revision: 82218
URL: http://svn.boost.org/trac/boost/changeset/82218

Log:
Fixing UB by using memcpy instead of old style cast

Text files modified:
   trunk/boost/functional/hash/detail/hash_float.hpp | 4 +++-
   1 files changed, 3 insertions(+), 1 deletions(-)

Modified: trunk/boost/functional/hash/detail/hash_float.hpp
==============================================================================
--- trunk/boost/functional/hash/detail/hash_float.hpp (original)
+++ trunk/boost/functional/hash/detail/hash_float.hpp 2012-12-27 05:49:19 EST (Thu, 27 Dec 2012)
@@ -73,7 +73,9 @@
                 ptr += sizeof(std::size_t);
 
                 while(length >= sizeof(std::size_t)) {
- hash_float_combine(seed, *(std::size_t*) ptr);
+ std::size_t buffer = 0;
+ std::memcpy(&buffer, ptr, sizeof(std::size_t));
+ hash_float_combine(seed, buffer);
                     length -= sizeof(std::size_t);
                     ptr += sizeof(std::size_t);
                 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk