From 865d44abe3877eadaec056b9c85b386ffed743ae Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Wed, 11 Oct 2023 16:11:12 -0700 Subject: [PATCH] Elide unaligned reads in header parse --- src/tinyusdz.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tinyusdz.cc b/src/tinyusdz.cc index c34f23fdf..fdc3fd480 100644 --- a/src/tinyusdz.cc +++ b/src/tinyusdz.cc @@ -341,8 +341,8 @@ bool ParseUSDZHeader(const uint8_t *addr, const size_t length, uint16_t compr_method = *reinterpret_cast(&local_header[0] + 8); // uint32_t compr_bytes = *reinterpret_cast(&local_header[0]+18); - uint32_t uncompr_bytes = - *reinterpret_cast(&local_header[0] + 22); + uint32_t uncompr_bytes; + memcpy(&uncompr_bytes, &local_header[22], sizeof(uncompr_bytes)); // USDZ only supports uncompressed ZIP if (compr_method != 0) {