mirror of
https://github.com/golang/go
synced 2024-11-22 05:04:40 -07:00
compress/flate: fix out of bounds error
Fixes #2508. R=rsc, krasin CC=golang-dev https://golang.org/cl/5449115
This commit is contained in:
parent
26089cfe25
commit
b1ae728d19
@ -319,8 +319,10 @@ Loop:
|
||||
// For matches this long, we don't bother inserting each individual
|
||||
// item into the table.
|
||||
d.index += d.length
|
||||
if d.index < d.maxInsertIndex {
|
||||
d.hash = (int(d.window[d.index])<<hashShift + int(d.window[d.index+1]))
|
||||
}
|
||||
}
|
||||
if d.ti == maxFlateBlockTokens {
|
||||
// The block includes the current character
|
||||
if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil {
|
||||
|
@ -318,3 +318,15 @@ func TestWriterDict(t *testing.T) {
|
||||
t.Fatalf("writer wrote %q want %q", b1.Bytes(), b.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
// See http://code.google.com/p/go/issues/detail?id=2508
|
||||
func TestRegression2508(t *testing.T) {
|
||||
w := NewWriter(ioutil.Discard, 1)
|
||||
buf := make([]byte, 1024)
|
||||
for i := 0; i < 131072; i++ {
|
||||
if _, err := w.Write(buf); err != nil {
|
||||
t.Fatalf("writer failed: %v", err)
|
||||
}
|
||||
}
|
||||
w.Close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user