]> 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, 18 Mar 2022 14:56:57 +0000 (15:56 +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 189b5ec4576c8fd2ec3834c586d6f7f6f5f29f52..9ea37225ec62b943e15e0dc3f12549c90d83c8c2 100644 (file)
@@ -171,5 +171,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;
 }