Big endian fix: load_u24_unaligned() must be consistent with loaded_u32_to_u24()
authorEric Biggers <ebiggers3@gmail.com>
Mon, 19 Oct 2015 00:39:26 +0000 (19:39 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 19 Oct 2015 00:48:15 +0000 (19:48 -0500)
include/wimlib/unaligned.h

index 34240bd..3fd35a4 100644 (file)
@@ -138,7 +138,11 @@ load_u24_unaligned(const u8 *p)
        return loaded_u32_to_u24(load_u32_unaligned(p));
 #else
 #  define LOAD_U24_REQUIRED_NBYTES 3
+#  if CPU_IS_BIG_ENDIAN
+       return ((u32)p[2] << 0) | ((u32)p[1] << 8) | ((u32)p[0] << 16);
+#  else
        return ((u32)p[0] << 0) | ((u32)p[1] << 8) | ((u32)p[2] << 16);
+#  endif
 #endif
 }