]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix a latent issue with chunkmemset
authorAdam Stylinski <kungfujesus06@gmail.com>
Fri, 18 Mar 2022 00:22:56 +0000 (20:22 -0400)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 17 Mar 2023 20:27:56 +0000 (21:27 +0100)
It would seem that on some platforms, namely those which are
!UNALIGNED64_OK, there was a likelihood of chunkmemset_safe_c copying all
the bytes before passing control flow to chunkcopy, a function which is
explicitly unsafe to be called with a zero length copy.

This fixes that bug for those platforms.

chunkset_tpl.h

index be52ee9f2fbdf43dac2248db72e82d1a69304f19..68728d4a5eed5da20339db724350b8e1888d7048 100644 (file)
@@ -200,5 +200,8 @@ Z_INTERNAL uint8_t* CHUNKMEMSET_SAFE(uint8_t *out, unsigned dist, unsigned len,
         }
         return out;
     }
-    return CHUNKMEMSET(out, dist, len);
+    if (len)
+        return CHUNKMEMSET(out, dist, len);
+
+    return out;
 }