Bug 1322112. Use memcpy() instead of dereferencing a casted pointer where the cast would increase alignement requirements on some architectures in nsIconDecoder. r=tnikkel
authorMartin Husemann <martin@NetBSD.ORG>
Thu, 08 Dec 2016 14:10:58 -0600
changeset 325671 5fd9bb569ce92abe307f52524fe414d5442b7373
parent 325670 48a1fc156b8dd4021670d639e93134b06d3b8044
child 325672 a430d66e076aeae2e0c2862c78977d8e26e29cdb
push id84761
push usertnikkel@gmail.com
push dateTue, 13 Dec 2016 05:06:46 +0000
treeherdermozilla-inbound@5fd9bb569ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1322112
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1322112. Use memcpy() instead of dereferencing a casted pointer where the cast would increase alignement requirements on some architectures in nsIconDecoder. r=tnikkel
image/decoders/nsIconDecoder.cpp
--- a/image/decoders/nsIconDecoder.cpp
+++ b/image/decoders/nsIconDecoder.cpp
@@ -89,17 +89,18 @@ nsIconDecoder::ReadRowOfPixels(const cha
 {
   MOZ_ASSERT(aLength % 4 == 0, "Rows should contain a multiple of four bytes");
 
   auto result = mPipe.WritePixels<uint32_t>([&]() -> NextPixel<uint32_t> {
     if (aLength == 0) {
       return AsVariant(WriteState::NEED_MORE_DATA);  // Done with this row.
     }
 
-    uint32_t pixel = *reinterpret_cast<const uint32_t*>(aData);
+    uint32_t pixel;
+    memcpy(&pixel, aData, 4);
     aData += 4;
     aLength -= 4;
 
     return AsVariant(pixel);
   });
 
   MOZ_ASSERT(result != WriteState::FAILURE);