Fix a nil pointer dereference error that occurs in tcpReader's Read method (#1090)

* Fix a `nil pointer dereference` error that occurs in `tcpReader`'s `Read` method

* #run_acceptance_tests

* #run_acceptance_tests

* Revert "Fix a `nil pointer dereference` error that occurs in `tcpReader`'s `Read` method"

This reverts commit ccef6cb393.

* Fix the race condition using locks #run_acceptance_tests
This commit is contained in:
M. Mert Yıldıran
2022-05-17 03:13:50 -07:00
committed by GitHub
parent 8418802c7e
commit fc194354bc
2 changed files with 7 additions and 1 deletions

View File

@@ -82,10 +82,14 @@ func (reader *tcpReader) isProtocolIdentified() bool {
}
func (reader *tcpReader) rewind() {
// Reset the data and msgBuffer from the master record
// Reset the data
reader.data = make([]byte, 0)
// Reset msgBuffer from the master record
reader.parent.Lock()
reader.msgBuffer = make([]api.TcpReaderDataMsg, len(reader.msgBufferMaster))
copy(reader.msgBuffer, reader.msgBufferMaster)
reader.parent.Unlock()
// Reset the read progress
reader.progress.Reset()