diff --git a/lib/compress/zstd_fast.c b/lib/compress/zstd_fast.c index 11c80af87fe..ecbc26d0419 100644 --- a/lib/compress/zstd_fast.c +++ b/lib/compress/zstd_fast.c @@ -183,7 +183,9 @@ ZSTD_compressBlock_fast_noDict_generic( offcode = REPCODE1_TO_OFFBASE; mLength += 4; - /* first write next hash table entry; we've already calculated it */ + /* First write next hash table entry; we've already calculated it. + * This write is known to be safe because the ip1 is before the + * repcode (ip2). */ hashTable[hash1] = (U32)(ip1 - base); goto _match; @@ -200,7 +202,9 @@ ZSTD_compressBlock_fast_noDict_generic( if (MEM_read32(ip0) == mval) { /* found a match! */ - /* first write next hash table entry; we've already calculated it */ + /* First write next hash table entry; we've already calculated it. + * This write is known to be safe because the ip1 == ip0 + 1, so + * we know we will resume searching after ip1 */ hashTable[hash1] = (U32)(ip1 - base); goto _offset; @@ -244,10 +248,6 @@ ZSTD_compressBlock_fast_noDict_generic( * ip1 is ip0 + step - 1. If ip1 is >= ip0 + 4, we can't safely * write this position. The expedient thing to do is just to * write a bad position. - * - * We perform this check here, separate from the write, because - * this is the only match path where this can occur. (In rep- - * code and the first match checks, ip1 == ip0 + 1.) */ hashTable[hash1] = (U32)(ip1 - base); }