]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Prevent stale stub functions from being called in deflate_slow
authorAdam Stylinski <kungfujesus06@gmail.com>
Mon, 21 Feb 2022 21:46:18 +0000 (16:46 -0500)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 23 Feb 2022 13:47:49 +0000 (14:47 +0100)
Just in case this is the very first call to longest match, we should
instead assign the function pointer instead of the function itself. This
way, by the time it leaves the stub, the function pointer gets
reassigned. This was found incidentally while debugging something else.

deflate_slow.c

index b8beec9ccd28d2f7c628d5e9766aeadd1c6956d9..20fa0f39ac7283660363dc19a7f627550a2e0847 100644 (file)
@@ -19,12 +19,12 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
     int bflush;              /* set if current block must be flushed */
     int64_t dist;
     uint32_t match_len;
-    match_func longest_match;
+    match_func *longest_match;
 
     if (s->max_chain_length <= 1024)
-        longest_match = functable.longest_match;
+        longest_match = &functable.longest_match;
     else
-        longest_match = functable.longest_match_slow;
+        longest_match = &functable.longest_match_slow;
 
     /* Process the input block. */
     for (;;) {
@@ -61,7 +61,7 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
              * of window index 0 (in particular we have to avoid a match
              * of the string with itself at the start of the input file).
              */
-            match_len = longest_match(s, hash_head);
+            match_len = (*longest_match)(s, hash_head);
             /* longest_match() sets match_start */
 
             if (match_len <= 5 && (s->strategy == Z_FILTERED)) {