diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2015-09-05 17:45:55 -0700 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-10-09 11:30:04 +0200 |
commit | e6a27bda7f73beb5f7c638ef5db9846b3d51941f (patch) | |
tree | a67e19836692e004ac6054f23daa7849ba437a0a /inflate.c | |
parent | b5b48c1883903ccbab7ec61d06352cdb9328dc0f (diff) |
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.
Diffstat (limited to 'inflate.c')
-rw-r--r-- | inflate.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1337,7 +1337,8 @@ long Z_EXPORT PREFIX(inflateMark)(PREFIX3(stream) *strm) { return -65536; INFLATE_MARK_HOOK(strm); /* hook for IBM Z DFLTCC */ state = (struct inflate_state *)strm->state; - return ((long)(state->back) << 16) + (state->mode == COPY ? state->length : + return (long)(((unsigned long)((long)state->back)) << 16) + + (state->mode == COPY ? state->length : (state->mode == MATCH ? state->was - state->length : 0)); } |