Skip to content

Commit

Permalink
Fix wrong error check in schemas.go
Browse files Browse the repository at this point in the history
The error is assigned to r.err but checked is err, fix this by checking r.err.
Found with nilness analyzer.

Fixes capnproto#147

Also delete unreachable return nil in marshal.go
  • Loading branch information
lukedirtwalker committed Aug 12, 2019
1 parent 9caa061 commit 42971e6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Jason E. Aten <[email protected]>
Johan Hernandez <[email protected]>
Joonsung Lee <[email protected]>
Lev Radomislensky <[email protected]>
Lukas Vogel <[email protected]> <[email protected]>
Martin Sucha <[email protected]>
Peter Waldschmidt <[email protected]>
Ross Light <[email protected]> <[email protected]>
Expand Down
1 change: 0 additions & 1 deletion encoding/text/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ func (enc *Encoder) marshalList(elem schema.Type, l capnp.List) error {
default:
return fmt.Errorf("unknown list type %v", elem.Which())
}
return nil
}

func (enc *Encoder) marshalEnum(typ uint64, val uint16) error {
Expand Down
2 changes: 1 addition & 1 deletion schemas/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *record) read() ([]byte, error) {
}
p := packed.NewReader(bufio.NewReader(z))
r.data, r.err = ioutil.ReadAll(p)
if err != nil {
if r.err != nil {
r.data = nil
return
}
Expand Down

0 comments on commit 42971e6

Please sign in to comment.