Fix usage of bytes.NewBuffer in bpfix

According to the documentation: "NewBuffer creates and initializes a new
Buffer using buf as its initial contents. The new Buffer takes ownership
of buf, and the caller should not use buf after this call."

Test: Run bpfix twice, only wrote the first time.
Change-Id: I52f88bfd9247240436b46f396c9196157774615b
This commit is contained in:
Dan Willemsen 2018-05-07 16:22:22 -07:00
parent 4339853a20
commit d6989f2e52
1 changed files with 1 additions and 1 deletions

View File

@ -65,7 +65,7 @@ func processFile(filename string, in io.Reader, out io.Writer, fixRequest bpfix.
if err != nil {
return err
}
r := bytes.NewBuffer(src)
r := bytes.NewBuffer(append([]byte(nil), src...))
file, errs := parser.Parse(filename, r, parser.NewScope(nil))
if len(errs) > 0 {
for _, err := range errs {