From e7d0e216d5288c24bbb85527808b7bf4794bfaba Mon Sep 17 00:00:00 2001 From: Francois Nedelec Date: Fri, 1 Apr 2022 14:34:04 +0100 Subject: [PATCH 1/3] Fixed alignment problems on MacOS --- miniz_tdef.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/miniz_tdef.c b/miniz_tdef.c index 13e03a2..7b13075 100644 --- a/miniz_tdef.c +++ b/miniz_tdef.c @@ -475,7 +475,7 @@ static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) if (flags & 1) { mz_uint s0, s1, n0, n1, sym, num_extra_bits; - mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); + mz_uint match_len = pLZ_codes[0]; match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3; MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); @@ -520,7 +520,7 @@ static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) if (pOutput_buf >= d->m_pOutput_buf_end) return MZ_FALSE; - *(mz_uint64 *)pOutput_buf = bit_buffer; + memcpy(pOutput_buf, &bit_buffer, 8); pOutput_buf += (bits_in >> 3); bit_buffer >>= (bits_in & ~7); bits_in &= 7; From bc77ea10177576ca8587868b87a372225670ded9 Mon Sep 17 00:00:00 2001 From: Martin Raiber Date: Fri, 6 May 2022 21:30:02 +0200 Subject: [PATCH 2/3] Update miniz_tdef.c Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com> --- miniz_tdef.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/miniz_tdef.c b/miniz_tdef.c index 7b13075..8dc33cd 100644 --- a/miniz_tdef.c +++ b/miniz_tdef.c @@ -475,7 +475,8 @@ static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) if (flags & 1) { mz_uint s0, s1, n0, n1, sym, num_extra_bits; - mz_uint match_len = pLZ_codes[0]; match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); + mz_uint match_len = pLZ_codes[0]; + match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3; MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); From 144c351f340f237879a371f7879bc6d8751d4b37 Mon Sep 17 00:00:00 2001 From: Martin Raiber Date: Fri, 6 May 2022 21:30:08 +0200 Subject: [PATCH 3/3] Update miniz_tdef.c Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com> --- miniz_tdef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miniz_tdef.c b/miniz_tdef.c index 8dc33cd..6f40934 100644 --- a/miniz_tdef.c +++ b/miniz_tdef.c @@ -521,7 +521,7 @@ static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) if (pOutput_buf >= d->m_pOutput_buf_end) return MZ_FALSE; - memcpy(pOutput_buf, &bit_buffer, 8); + memcpy(pOutput_buf, &bit_buffer, sizeof(mz_uint64)); pOutput_buf += (bits_in >> 3); bit_buffer >>= (bits_in & ~7); bits_in &= 7;