fix: memory leak in influx parser (#9787)

This commit is contained in:
Patrick Hemmer 2021-10-07 16:35:44 -04:00 committed by GitHub
parent 15753a6f7f
commit 128ed8849b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View File

@ -3747,13 +3747,6 @@ func (m *streamMachine) Next() error {
m.machine.finishMetric = false
for {
// Expand the buffer if it is full
if m.machine.pe == len(m.machine.data) {
expanded := make([]byte, 2*len(m.machine.data))
copy(expanded, m.machine.data)
m.machine.data = expanded
}
err := m.machine.exec()
if err != nil {
return err
@ -3764,6 +3757,13 @@ func (m *streamMachine) Next() error {
break
}
// Expand the buffer if it is full
if m.machine.pe == len(m.machine.data) {
expanded := make([]byte, 2*len(m.machine.data))
copy(expanded, m.machine.data)
m.machine.data = expanded
}
n, err := m.reader.Read(m.machine.data[m.machine.pe:])
if n == 0 && err == io.EOF {
m.machine.eof = m.machine.pe

View File

@ -499,13 +499,6 @@ func (m *streamMachine) Next() error {
m.machine.finishMetric = false
for {
// Expand the buffer if it is full
if m.machine.pe == len(m.machine.data) {
expanded := make([]byte, 2 * len(m.machine.data))
copy(expanded, m.machine.data)
m.machine.data = expanded
}
err := m.machine.exec()
if err != nil {
return err
@ -516,6 +509,13 @@ func (m *streamMachine) Next() error {
break
}
// Expand the buffer if it is full
if m.machine.pe == len(m.machine.data) {
expanded := make([]byte, 2 * len(m.machine.data))
copy(expanded, m.machine.data)
m.machine.data = expanded
}
n, err := m.reader.Read(m.machine.data[m.machine.pe:])
if n == 0 && err == io.EOF {
m.machine.eof = m.machine.pe