]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
clang optimizer bug workaround
authorYann Collet <yann.collet.73@gmail.com>
Tue, 20 Oct 2015 02:01:38 +0000 (03:01 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Tue, 20 Oct 2015 02:01:38 +0000 (03:01 +0100)
lib/zstd.c

index 716a467a006826e132d8fae2373e416f8a43f8de..35ed16e48c70c5c8b4aa3b4b12f0ae774e056803 100644 (file)
@@ -1323,8 +1323,9 @@ static size_t ZSTD_execSequence(BYTE* op,
         const BYTE* match = op - sequence.offset;
 
         /* check */
+        if (sequence.offset > (size_t)op) return ERROR(corruption_detected);   /* address space overflow test (this test seems kept by clang optimizer) */
+        //if (match > op) return ERROR(corruption_detected);   /* address space overflow test (is clang optimizer removing this test ?) */
         if (match < base) return ERROR(corruption_detected);
-        if (match > op) return ERROR(corruption_detected);   /* address space overflow test */
 
         /* close range match, overlap */
         if (sequence.offset < 8)
@@ -1337,7 +1338,11 @@ static size_t ZSTD_execSequence(BYTE* op,
             match += dec32table[sequence.offset];
             ZSTD_copy4(op+4, match);
             match -= dec64;
-        } else { ZSTD_copy8(op, match); }
+        }
+        else
+        {
+            ZSTD_copy8(op, match);
+        }
         op += 8; match += 8;
 
         if (oMatchEnd > oend-12)