Skip to content

Commit

Permalink
Merge pull request #22 from tris/master
Browse files Browse the repository at this point in the history
Fix memory corruption in io.Writer interface
  • Loading branch information
ZachtimusPrime authored Aug 19, 2021
2 parents 49a10eb + 40522e0 commit f3be3a1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion splunk/v2/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ func (w *Writer) Write(b []byte) (int, error) {
w.errors = make(chan error, bufferSize)
go w.listen()
})
// Make a local copy of the bytearray so it doesn't get overwritten by
// the next call to Write()
var b2 = make([]byte, len(b))
copy(b2, b)
// Send the data to the channel
w.dataChan <- &message{
data: b,
data: b2,
writtenAt: time.Now(),
}
// We don't know if we've hit any errors yet, so just say we're good
Expand Down

0 comments on commit f3be3a1

Please sign in to comment.