]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
early return as requested
authorLucy Phipps <landfillbaby69@gmail.com>
Wed, 8 Jun 2022 17:48:19 +0000 (18:48 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 17 Mar 2023 20:27:56 +0000 (21:27 +0100)
arch/arm/crc32_acle.c

index dc56815e9c5ba53b218ad22c1ec2286e142003c8..37b1b98a2121a81b99ada3329abb98a1907f7d94 100644 (file)
@@ -37,6 +37,11 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) {
         len -= sizeof(uint32_t);
     }
 
+    if (len == 0) {
+        c = ~c;
+        return c;
+    }
+
     const uint64_t *buf8 = (const uint64_t *) buf4;
 
     while (len >= sizeof(uint64_t)) {
@@ -61,6 +66,11 @@ uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) {
     buf = (const unsigned char *) buf2;
 #else /* __aarch64__ */
 
+    if (len == 0) {
+        c = ~c;
+        return c;
+    }
+
     while (len >= sizeof(uint32_t)) {
         c = __crc32w(c, *buf4++);
         len -= sizeof(uint32_t);