]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Consume bits before branches in inflate_fast.
authorDougall Johnson <dougallj@gmail.com>
Sun, 28 Dec 2025 23:41:02 +0000 (15:41 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 6 Jan 2026 23:14:31 +0000 (00:14 +0100)
inffast_tpl.h

index 4798d81eb5c29cf75144c477736349206ffbd7cb..4b1447cb703b3eb4dfacadc599ff08ccbfc6e0fd 100644 (file)
@@ -151,20 +151,20 @@ void Z_INTERNAL INFLATE_FAST(PREFIX3(stream) *strm, uint32_t start) {
         REFILL();
         here = lcode[hold & lmask];
         Z_TOUCH(here);
+        DROPBITS(here.bits);
         if (here.op == 0) {
             *out++ = (unsigned char)(here.val);
-            DROPBITS(here.bits);
             here = lcode[hold & lmask];
             Z_TOUCH(here);
+            DROPBITS(here.bits);
             if (here.op == 0) {
                 *out++ = (unsigned char)(here.val);
-                DROPBITS(here.bits);
                 here = lcode[hold & lmask];
                 Z_TOUCH(here);
+                DROPBITS(here.bits);
             }
         }
       dolen:
-        DROPBITS(here.bits);
         op = here.op;
         if (op == 0) {                          /* literal */
             Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
@@ -291,6 +291,7 @@ void Z_INTERNAL INFLATE_FAST(PREFIX3(stream) *strm, uint32_t start) {
         } else if ((op & 64) == 0) {              /* 2nd level length code */
             here = lcode[here.val + BITS(op)];
             Z_TOUCH(here);
+            DROPBITS(here.bits);
             goto dolen;
         } else if (op & 32) {                     /* end-of-block */
             Tracevv((stderr, "inflate:         end of block\n"));