From 7f740f1308336e9ec0afdb9434896307859f5dc9 Mon Sep 17 00:00:00 2001 From: Eugene Kliuchnikov Date: Fri, 15 May 2020 11:06:21 +0200 Subject: 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 --- go/cbrotli/cbrotli_test.go | 4 ++++ go/cbrotli/reader.go | 3 +++ 2 files changed, 7 insertions(+) (limited to 'go') 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 { -- cgit v1.1