From: NiLuJe Date: Sun, 2 Aug 2020 18:22:04 +0000 (+0200) Subject: Prevent unaligned double word access on ARMv7 in put_uint64 X-Git-Tag: 1.9.9-b1~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fccbde10c91295a74df6363b4e08259b0d855f0;p=thirdparty%2Fzlib-ng.git Prevent unaligned double word access on ARMv7 in put_uint64 By implementing a (UNALIGNED_OK && !UNALIGNED64_OK) codepath. --- diff --git a/deflate.h b/deflate.h index 600fca6d2..ce6106cff 100644 --- a/deflate.h +++ b/deflate.h @@ -351,9 +351,14 @@ static inline void put_uint32_msb(deflate_state *s, uint32_t dw) { * IN assertion: there is enough room in pending_buf. */ static inline void put_uint64(deflate_state *s, uint64_t lld) { -#if defined(UNALIGNED_OK) +#if defined(UNALIGNED64_OK) *(uint64_t *)(&s->pending_buf[s->pending]) = lld; s->pending += 8; +#elif defined(UNALIGNED_OK) + *(uint32_t *)(&s->pending_buf[s->pending]) = lld & 0xffffffff; + s->pending += 4; + *(uint32_t *)(&s->pending_buf[s->pending]) = (lld >> 32) & 0xffffffff; + s->pending += 4; #else put_byte(s, (lld & 0xff)); put_byte(s, ((lld >> 8) & 0xff));