diff options
author | Eugene Kliuchnikov <eustas.ru@gmail.com> | 2020-05-15 11:06:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-15 11:06:21 +0200 |
commit | 7f740f1308336e9ec0afdb9434896307859f5dc9 (patch) | |
tree | 72841d92798fabcfaec0b95091420ac37c82b86f /go | |
parent | f83aa5169e3c09afa8db84d1180fd1fe8813118a (diff) | |
download | brotli-7f740f1308336e9ec0afdb9434896307859f5dc9.zip brotli-7f740f1308336e9ec0afdb9434896307859f5dc9.tar.gz brotli-7f740f1308336e9ec0afdb9434896307859f5dc9.tar.bz2 |
Update (#807)
- fix formatting
- fix type conversion
- fix no-op arithmetic with null-pointer
- improve performance of hash_longest_match64
- go: detect read after close
- java decoder: support compound dictionary
- remove executable flag on non-scripts
Diffstat (limited to 'go')
-rw-r--r-- | go/cbrotli/cbrotli_test.go | 4 | ||||
-rw-r--r-- | go/cbrotli/reader.go | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/go/cbrotli/cbrotli_test.go b/go/cbrotli/cbrotli_test.go index f59ec58..36ad2ba 100644 --- a/go/cbrotli/cbrotli_test.go +++ b/go/cbrotli/cbrotli_test.go @@ -274,6 +274,10 @@ func TestReader(t *testing.T) { "<%d bytes>", got, len(content)) } + buf := make([]byte, 4) + if _, err := r.Read(buf); err != errReaderClosed { + t.Errorf("Read-after-Close returned %v, expected %v", err, errReaderClosed) + } } func TestDecode(t *testing.T) { diff --git a/go/cbrotli/reader.go b/go/cbrotli/reader.go index 3d8d424..6e390c3 100644 --- a/go/cbrotli/reader.go +++ b/go/cbrotli/reader.go @@ -82,6 +82,9 @@ func (r *Reader) Close() error { } func (r *Reader) Read(p []byte) (n int, err error) { + if r.state == nil { + return 0, errReaderClosed + } if int(C.BrotliDecoderHasMoreOutput(r.state)) == 0 && len(r.in) == 0 { m, readErr := r.src.Read(r.buf) if m == 0 { |