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
diff --git a/bpfix/cmd/bpfix.go b/bpfix/cmd/bpfix.go
index 2fde383..ccdae16 100644
--- a/bpfix/cmd/bpfix.go
+++ b/bpfix/cmd/bpfix.go
@@ -65,7 +65,7 @@
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 {