Bug 643137 - strict alignment issues when displaying OpenType fonts on sparc64. r=roc
authorLandry Breuil <landry@openbsd.org>
Sat, 26 Mar 2011 17:04:18 +0100
changeset 64018 86d254c4f03462b707237f4c0c0df947c6235246
parent 64017 151bbff21acf200d595821c802904dab6625ac76
child 64019 a1cae3aa90d71058513e2f01ac3e3e449deffa3c
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs643137
milestone2.2a1pre
Bug 643137 - strict alignment issues when displaying OpenType fonts on sparc64. r=roc
gfx/ots/include/opentype-sanitiser.h
--- a/gfx/ots/include/opentype-sanitiser.h
+++ b/gfx/ots/include/opentype-sanitiser.h
@@ -63,18 +63,20 @@ class OTSStream {
 
     if (chksum_buffer_offset_ == 4) {
       // TODO(yusukes): This cast breaks the strict-aliasing rule.
       chksum_ += ntohl(*reinterpret_cast<const uint32_t*>(chksum_buffer_));
       chksum_buffer_offset_ = 0;
     }
 
     while (length >= 4) {
-      chksum_ += ntohl(*reinterpret_cast<const uint32_t*>(
-          reinterpret_cast<const uint8_t*>(data) + offset));
+      uint32_t tmp;
+      std::memcpy(&tmp, reinterpret_cast<const uint8_t *>(data) + offset,
+        sizeof(uint32_t));
+      chksum_ += ntohl(tmp);
       length -= 4;
       offset += 4;
     }
 
     if (length) {
       if (chksum_buffer_offset_ != 0) return false;  // not reached
       if (length > 4) return false;  // not reached
       std::memcpy(chksum_buffer_,