• Ehren Kret's avatar
    compress/flate: prevent panic when reinitializing huffmanDecoder with bad input · 3b6b53f4
    Ehren Kret authored
    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
    3b6b53f4
flate_test.go 1.78 KB