Skip to content

Commit 900b778

Browse files
committed
Backport level 9 single value fix
Change-Id: I141da3cb0337e1e255ed621b1a14667464821459
1 parent 3ecd6c2 commit 900b778

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/compress/flate/deflate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@ func (d *compressor) deflateLazy() {
395395
d.h = newHuffmanEncoder(maxFlateBlockTokens)
396396
}
397397
var tmp [256]uint16
398-
for _, v := range d.window[s.index:d.windowEnd] {
398+
toIndex := d.window[s.index:d.windowEnd]
399+
toIndex = toIndex[:min(len(toIndex), maxFlateBlockTokens)]
400+
for _, v := range toIndex {
399401
tmp[v]++
400402
}
401403
d.h.generate(tmp[:], 15)

src/compress/flate/huffman_bit_writer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ func (w *huffmanBitWriter) writeBlockDynamic(tokens *tokens, eof bool, input []b
620620
sync = sync || eof
621621
if sync {
622622
tokens.AddEOB()
623+
} else {
624+
// Ensure we can always write EOB.
625+
tokens.extraHist[0] = 1
623626
}
624627

625628
// We cannot reuse pure huffman table, and must mark as EOF.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)