diff --git a/backward_references_hq.go b/backward_references_hq.go index 5eac736..bd2de48 100644 --- a/backward_references_hq.go +++ b/backward_references_hq.go @@ -502,7 +502,9 @@ func updateNodes(num_bytes uint, block_start uint, pos uint, ringbuffer []byte, var cost float32 = dist_cost + float32(getCopyExtra(copycode)) + zopfliCostModelGetCommandCost(model, cmdcode) if cost < nodes[pos+len].u.cost { updateZopfliNode(nodes, pos, start, uint(len), len_code, dist, 0, cost) - result = brotli_max_size_t(result, uint(len)) + if len > result { + result = len + } } } } diff --git a/find_match_length.go b/find_match_length.go index 14d350a..6730119 100644 --- a/find_match_length.go +++ b/find_match_length.go @@ -9,6 +9,7 @@ package brotli /* Function to find maximal matching prefixes of strings. */ func findMatchLengthWithLimit(s1 []byte, s2 []byte, limit uint) uint { var matched uint = 0 + _, _ = s1[limit-1], s2[limit-1] // bounds check for matched < limit && s1[matched] == s2[matched] { matched++ }