From f7d01aae6ec6115184de821b93fa47810abd88f9 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Mon, 26 Aug 2024 23:51:11 -0700 Subject: [PATCH] Avoid out-of-bounds pointer arithmetic in inflateCopy(). Though it does not matter for code correctness, clang's UBSan injects code that complains about computing a pointer from an array where the result is out-of-bounds for that array, even though the pointer is never dereferenced. Go figure. This commit avoids that possibility when computing distcode in inflateCopy(). --- inflate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inflate.c b/inflate.c index e2fa6bb..4feac09 100644 --- a/inflate.c +++ b/inflate.c @@ -923,7 +923,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; - state->lencode = (const code FAR *)(state->next); + state->lencode = state->distcode = (const code FAR *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work);