]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.7] compress/flate: make huffmanBitWriter errors persistent
authorJoe Tsai <joetsai@digital-static.net>
Tue, 16 Aug 2016 23:03:00 +0000 (16:03 -0700)
committerChris Broadfoot <cbro@golang.org>
Wed, 7 Sep 2016 17:45:45 +0000 (17:45 +0000)
commitc0f5de1ad275cf9a2d7f572be76e7b10fcd3e48f
tree15aab205ba2a8f0d3361ab9fd2db3b8b607bec7d
parent1861ac159eac4b7db1a6c206c0edb1ab1bfef0d9
[release-branch.go1.7] compress/flate: make huffmanBitWriter errors persistent

For persistent error handling, the methods of huffmanBitWriter have to be
consistent about how they check errors. It must either consistently
check error *before* every operation OR immediately *after* every
operation. Since most of the current logic uses the previous approach,
we apply the same style of error checking to writeBits and all calls
to Write such that they only operate if w.err is already nil going
into them.

The error handling approach is brittle and easily broken by future commits to
the code. In the near future, we should switch the logic to use panic at the
lowest levels and a recover at the edge of the public API to ensure
that errors are always persistent.

Fixes #16749

Change-Id: Ie1d83e4ed8842f6911a31e23311cd3cbf38abe8c
Reviewed-on: https://go-review.googlesource.com/27200
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/28634
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
src/compress/flate/deflate.go
src/compress/flate/deflate_test.go
src/compress/flate/huffman_bit_writer.go