Skip to content

Commit 2afb9a3

Browse files
committed
Make cost at least 1 for safety
Change-Id: I005e18aa982b24c02c1163470e3d7e7794358543
1 parent 900b778 commit 2afb9a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/compress/flate/huffman_code.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (h *huffmanEncoder) bitLength(freq []uint16) int {
143143
func (h *huffmanEncoder) bitLengthRaw(b []byte) int {
144144
var total int
145145
for _, f := range b {
146-
total += int(h.codes[f].len())
146+
total += max(1, int(h.codes[f].len()))
147147
}
148148
return total
149149
}

0 commit comments

Comments
 (0)