From 335780c427e365e1c3c7e7ae96acbf79f9b36f19 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 13 Sep 2017 16:35:29 -0700 Subject: [PATCH] fixed too strong alignment assert in ZSTD_initStaticCCtx() 64-bits fields are only 32-bits aligned on 32-bits CPU --- lib/compress/zstd_compress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 9f59ea686..f35a44e4c 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -87,7 +87,7 @@ ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem) ZSTD_CCtx* ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize) { - ZSTD_CCtx* cctx = (ZSTD_CCtx*) workspace; + ZSTD_CCtx* const cctx = (ZSTD_CCtx*) workspace; if (workspaceSize <= sizeof(ZSTD_CCtx)) return NULL; /* minimum size */ if ((size_t)workspace & 7) return NULL; /* must be 8-aligned */ memset(workspace, 0, workspaceSize); /* may be a bit generous, could memset be smaller ? */ @@ -97,7 +97,7 @@ ZSTD_CCtx* ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize) /* entropy space (never moves) */ if (cctx->workSpaceSize < sizeof(ZSTD_entropyCTables_t)) return NULL; - assert(((size_t)cctx->workSpace & 7) == 0); /* ensure correct alignment */ + assert(((size_t)cctx->workSpace & (sizeof(void*)-1)) == 0); /* ensure correct alignment */ cctx->entropy = (ZSTD_entropyCTables_t*)cctx->workSpace; return cctx;