aboutsummaryrefslogtreecommitdiff
path: root/src/compress/flate/deflatefast.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2020-11-13 03:04:52 +0100
committerFilippo Valsorda <filippo@golang.org>2020-11-13 03:04:52 +0100
commit11087322f85d5ace6494fc194982d92f0a34df0f (patch)
tree1fc71e2b2e13647ad4a2a86f95794b47ca950e99 /src/compress/flate/deflatefast.go
parented9dc25d693c02aeeb8ed084b28b6d7f9489dc5a (diff)
parentc53315d6cf1b4bfea6ff356b4a1524778c683bb9 (diff)
downloadgo-11087322f85d5ace6494fc194982d92f0a34df0f.tar.gz
go-11087322f85d5ace6494fc194982d92f0a34df0f.zip
[dev.boringcrypto.go1.15] all: merge go1.15.5 into dev.boringcrypto.go1.15
Change-Id: I075fd29b5d035cac905c7bc3145405bf622a981b
Diffstat (limited to 'src/compress/flate/deflatefast.go')
-rw-r--r--src/compress/flate/deflatefast.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/compress/flate/deflatefast.go b/src/compress/flate/deflatefast.go
index 24f8be9d5d..6aa439f13d 100644
--- a/src/compress/flate/deflatefast.go
+++ b/src/compress/flate/deflatefast.go
@@ -270,6 +270,7 @@ func (e *deflateFast) matchLen(s, t int32, src []byte) int32 {
func (e *deflateFast) reset() {
e.prev = e.prev[:0]
// Bump the offset, so all matches will fail distance check.
+ // Nothing should be >= e.cur in the table.
e.cur += maxMatchOffset
// Protect against e.cur wraparound.
@@ -288,17 +289,21 @@ func (e *deflateFast) shiftOffsets() {
for i := range e.table[:] {
e.table[i] = tableEntry{}
}
- e.cur = maxMatchOffset
+ e.cur = maxMatchOffset + 1
return
}
// Shift down everything in the table that isn't already too far away.
for i := range e.table[:] {
- v := e.table[i].offset - e.cur + maxMatchOffset
+ v := e.table[i].offset - e.cur + maxMatchOffset + 1
if v < 0 {
+ // We want to reset e.cur to maxMatchOffset + 1, so we need to shift
+ // all table entries down by (e.cur - (maxMatchOffset + 1)).
+ // Because we ignore matches > maxMatchOffset, we can cap
+ // any negative offsets at 0.
v = 0
}
e.table[i].offset = v
}
- e.cur = maxMatchOffset
+ e.cur = maxMatchOffset + 1
}