Skip to content

Commit

Permalink
s2: Fix crash on small better buffers (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost authored Jan 8, 2021
1 parent 39a5f72 commit b45090e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions s2/encode_better.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func encodeBlockBetter(dst, src []byte) (d int) {
// lets us use a fast path for emitLiteral in the main loop, while we are
// looking for copies.
sLimit := len(src) - inputMargin
if len(src) < minNonLiteralBlockSize {
return 0
}

// Bail if we can't compress to at least this.
dstLimit := len(src) - len(src)>>5 - 5
Expand Down

0 comments on commit b45090e

Please sign in to comment.