Skip to content

Commit

Permalink
Avoid out-of-bounds pointer arithmetic in inflateCopy().
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
madler committed Sep 1, 2024
1 parent 2968a49 commit f7d01aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f7d01aa

Please sign in to comment.