]> Cypherpunks repositories - gostls13.git/commit
compress/flate: prevent panic when reinitializing huffmanDecoder with bad input
authorEhren Kret <ehren.kret@gmail.com>
Fri, 6 Sep 2013 22:09:42 +0000 (15:09 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 6 Sep 2013 22:09:42 +0000 (15:09 -0700)
commit3b6b53f493af5984ca50cc202c3f8e155ad6f526
tree8e7da1e96aa159bc59ef497fa6ffc917285f8082
parent187241582e1de5a8bb3bcfc6545a062f11c4d12d
compress/flate: prevent panic when reinitializing huffmanDecoder with bad input

The huffmanDecoder struct appears to be intented for reuse by calling init a
second time with a second sequence of code lengths. Unfortunately, it can
currently panic if the second sequence of code lengths has a minimum value
greater than 10 due to failure to reinitialize the links table.

This change prevents the panic by resetting the huffmanDecoder struct back to
the struct's zero value at the beginning of the init method if the
huffmanDecoder is being reused (determined by checking if min has been set to a
non-zero value).

Fixes #6255.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13230043
src/pkg/compress/flate/flate_test.go
src/pkg/compress/flate/inflate.go