aboutsummaryrefslogtreecommitdiff
path: root/c/enc/hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/enc/hash.h')
-rw-r--r--c/enc/hash.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/c/enc/hash.h b/c/enc/hash.h
index d993b6a..ba9b0d8 100644
--- a/c/enc/hash.h
+++ b/c/enc/hash.h
@@ -557,7 +557,6 @@ static BROTLI_INLINE void FindCompoundDictionaryMatch(
offset = distance_offset - distance;
limit = source_size - offset;
limit = limit > max_length ? max_length : limit;
- BROTLI_DCHECK(cur_ix_masked + limit <= ring_buffer_mask);
len = FindMatchLengthWithLimit(&source[offset], &data[cur_ix_masked],
limit);
if (len >= 2) {
@@ -592,7 +591,7 @@ static BROTLI_INLINE void FindCompoundDictionaryMatch(
limit = source_size - offset;
limit = (limit > max_length) ? max_length : limit;
if (distance > max_distance) continue;
- if (best_len >= limit ||
+ if (cur_ix_masked + best_len > ring_buffer_mask || best_len >= limit ||
/* compare 4 bytes ending at best_len + 1 */
BrotliUnalignedRead32(&data[cur_ix_masked + best_len - 3]) !=
BrotliUnalignedRead32(&source[offset + best_len - 3])) {
@@ -671,7 +670,8 @@ static BROTLI_INLINE size_t FindAllCompoundDictionaryMatches(
limit = source_size - offset;
limit = (limit > max_length) ? max_length : limit;
if (distance > max_distance) continue;
- if (best_len >= limit ||
+ if (cur_ix_masked + best_len > ring_buffer_mask ||
+ best_len >= limit ||
data[cur_ix_masked + best_len] != source[offset + best_len]) {
continue;
}