]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
factor out code
authorSebastian Pop <s.pop@samsung.com>
Wed, 6 Mar 2019 20:00:30 +0000 (14:00 -0600)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 21 Mar 2019 10:22:36 +0000 (11:22 +0100)
inflate.c

index c4241cc676adb4c8bd3e0a5e990fed54c20bbb46..293081ab4d04888bb0860b895b22dc9ec788d9ce 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -1164,25 +1164,21 @@ int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) {
                     copy = state->length;
                 if (copy > left)
                     copy = left;
-                left -= copy;
-                state->length -= copy;
                 if (copy >= sizeof(uint64_t))
                     put = chunk_memcpy(put, from, copy);
                 else
                     put = copy_bytes(put, from, copy);
             } else {                             /* copy from output */
-                unsigned offset = state->offset;
-                from = put - offset;
                 copy = state->length;
                 if (copy > left)
                     copy = left;
-                left -= copy;
-                state->length -= copy;
                 if (copy >= sizeof(uint64_t))
-                    put = chunk_memset(put, from, offset, copy);
+                    put = chunk_memset(put, put - state->offset, state->offset, copy);
                 else
-                    put = set_bytes(put, from, offset, copy);
+                    put = set_bytes(put, put - state->offset, state->offset, copy);
             }
+            left -= copy;
+            state->length -= copy;
             if (state->length == 0)
                 state->mode = LEN;
             break;