Skip to content

Commit e54e129

Browse files
committed
Avoid shifts of negative values inflateMark().
The C standard says that bit shifts of negative integers is undefined. This casts to unsigned values to assure a known result.
1 parent 27ef026 commit e54e129

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

inflate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,9 +1506,10 @@ z_streamp strm;
15061506
{
15071507
struct inflate_state FAR *state;
15081508

1509-
if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
1509+
if (strm == Z_NULL || strm->state == Z_NULL)
1510+
return (long)(((unsigned long)0 - 1) << 16);
15101511
state = (struct inflate_state FAR *)strm->state;
1511-
return ((long)(state->back) << 16) +
1512+
return (long)(((unsigned long)((long)state->back)) << 16) +
15121513
(state->mode == COPY ? state->length :
15131514
(state->mode == MATCH ? state->was - state->length : 0));
15141515
}

0 commit comments

Comments
 (0)