aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas.ru@gmail.com>2020-05-15 11:06:21 +0200
committerGitHub <noreply@github.com>2020-05-15 11:06:21 +0200
commit7f740f1308336e9ec0afdb9434896307859f5dc9 (patch)
tree72841d92798fabcfaec0b95091420ac37c82b86f /go
parentf83aa5169e3c09afa8db84d1180fd1fe8813118a (diff)
downloadbrotli-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.go4
-rw-r--r--go/cbrotli/reader.go3
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 {