]> git.lizzy.rs Git - zlib.git/blobdiff - inflate.c
Avoid shifts of negative values inflateMark().
[zlib.git] / inflate.c
index 2889e3a07d6d425946fc807f0be6b9156ecc1444..a71841670eff6476d3b86a49dcf91acdf2e7bb3f 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -1506,9 +1506,10 @@ z_streamp strm;
 {
     struct inflate_state FAR *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return (long)(((unsigned long)0 - 1) << 16);
     state = (struct inflate_state FAR *)strm->state;
-    return ((long)(state->back) << 16) +
+    return (long)(((unsigned long)((long)state->back)) << 16) +
         (state->mode == COPY ? state->length :
             (state->mode == MATCH ? state->was - state->length : 0));
 }