From: Vladimir Vukicevic <vladimir@pobox.com>
Date: Tue, 8 Sep 2009 11:36:28 -0400
Subject: Bug 504766. qcms: Fix unaligned reads in qcms. r=jrmuizel

---
 gfx/qcms/iccread.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gfx/qcms/iccread.c b/gfx/qcms/iccread.c
index 7cc5d7f..6671c73 100644
--- a/gfx/qcms/iccread.c
+++ b/gfx/qcms/iccread.c
@@ -87,7 +87,9 @@ static uint32_t read_u32(struct mem_source *mem, size_t offset)
 		invalid_source(mem, "Invalid offset");
 		return 0;
 	} else {
-		return be32_to_cpu(*(__be32*)(mem->buf + offset));
+		__be32 k;
+		memcpy(&k, mem->buf + offset, sizeof(__be32));
+		return be32_to_cpu(k);
 	}
 }
 
@@ -97,7 +99,9 @@ static uint16_t read_u16(struct mem_source *mem, size_t offset)
 		invalid_source(mem, "Invalid offset");
 		return 0;
 	} else {
-		return be16_to_cpu(*(__be16*)(mem->buf + offset));
+		__be16 k;
+		memcpy(&k, mem->buf + offset, sizeof(__be16));
+		return be16_to_cpu(k);
 	}
 }
 
