Skip to content

Commit

Permalink
Remove undefined behavior during return (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhendrixMSFT authored Apr 27, 2023
1 parent 553a90a commit c2958ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions autorest/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ func NewDecoder(encodedAs EncodedAs, r io.Reader) Decoder {
// is especially useful if there is a chance the data will fail to decode.
// encodedAs specifies the expected encoding, r provides the io.Reader to the data, and v
// is the decoding destination.
func CopyAndDecode(encodedAs EncodedAs, r io.Reader, v interface{}) (bytes.Buffer, error) {
b := bytes.Buffer{}
return b, NewDecoder(encodedAs, io.TeeReader(r, &b)).Decode(v)
func CopyAndDecode(encodedAs EncodedAs, r io.Reader, v interface{}) (b bytes.Buffer, err error) {
err = NewDecoder(encodedAs, io.TeeReader(r, &b)).Decode(v)
return
}

// TeeReadCloser returns a ReadCloser that writes to w what it reads from rc.
Expand Down

0 comments on commit c2958ac

Please sign in to comment.