Skip to content

Commit

Permalink
Merge pull request #3 from vikstrous/fix-nil-pointer
Browse files Browse the repository at this point in the history
fix nil pointer encoding nil big.Int to zarith
  • Loading branch information
gavi-anchorlabs authored Sep 10, 2019
2 parents f15af1d + 63eb4c1 commit 3c05ba2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zarith/zarith.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func ReadNext(byteStream []byte) (*big.Int, int, error) {

// Encode encodes a number to zarith
func Encode(value *big.Int) ([]byte, error) {
if value == nil {
value = big.NewInt(0)
}
if value.Sign() == -1 {
return nil, xerrors.Errorf("cannot encode negative integer: %s", value)
}
Expand Down

0 comments on commit 3c05ba2

Please sign in to comment.