From 34799666442565d2caa49e83697e6849064c7687 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Thu, 17 Jan 2019 13:07:16 -0600 Subject: [PATCH] fix bug #208: let the compiler generate code for unaligned stores to avoid this error: zlib-ng/arch/x86/deflate_quick.c:154:5: runtime error: store to misaligned address 0x631000014801 for type 'unsigned int', which requires 4 byte alignment 0x631000014801: note: pointer points here 00 80 02 d3 07 00 00 be be be be be be be be be be be be be be be be be be be be be be be be be ^ SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior zlib-ng/arch/x86/deflate_quick.c:154:5 in --- arch/x86/deflate_quick.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/deflate_quick.c b/arch/x86/deflate_quick.c index 9fb321d1..9968b960 100644 --- a/arch/x86/deflate_quick.c +++ b/arch/x86/deflate_quick.c @@ -23,6 +23,7 @@ # include #endif #include "deflate.h" +#include "memcopy.h" #ifdef ZLIB_DEBUG #include @@ -151,7 +152,7 @@ static inline void quick_send_bits(deflate_state *const s, s->bi_valid = width - (bytes_out * 8); /* Taking advantage of the fact that LSB comes first, write to output buffer */ - *(unsigned *)(s->pending_buf + s->pending) = out; + MEMCPY(s->pending_buf + s->pending, &out, sizeof(out)); s->pending += bytes_out; } -- 2.47.2