Skip to content

Commit 85af151

Browse files
authored
fix(io): file source ignore endLine buffer (#3431) (#3433)
Signed-off-by: Jiyong Huang <[email protected]>
1 parent dddcd8d commit 85af151

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/io/file/source.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package file
1616

1717
import (
1818
"bufio"
19+
"bytes"
1920
"errors"
2021
"fmt"
2122
"io"
@@ -325,7 +326,7 @@ func ignoreLines(ctx api.StreamContext, reader io.Reader, decorator modules.File
325326
if ignoreEndLines > 0 { // the last n line are left in the tempLines
326327
slot := (ln - ignoreStartLines) % ignoreEndLines
327328
if len(tempLines) <= slot { // first round
328-
tempLines = append(tempLines, scanner.Bytes())
329+
tempLines = append(tempLines, bytes.Clone(scanner.Bytes()))
329330
} else {
330331
_, err := w.Write(tempLines[slot])
331332
if err != nil {
@@ -337,7 +338,7 @@ func ignoreLines(ctx api.StreamContext, reader io.Reader, decorator modules.File
337338
ctx.GetLogger().Error(err)
338339
break
339340
}
340-
tempLines[slot] = scanner.Bytes()
341+
tempLines[slot] = bytes.Clone(scanner.Bytes())
341342
}
342343
} else {
343344
_, err := w.Write(scanner.Bytes())

0 commit comments

Comments
 (0)