Skip to content

Commit

Permalink
fix: nil pointer panic on NewIntFromBigInt (backport cosmos#9627) (c…
Browse files Browse the repository at this point in the history
…osmos#10845)

* types: fix nil pointer panic on `NewIntFromBigInt` (cosmos#9627)

(cherry picked from commit 7f90374)

# Conflicts:
#	CHANGELOG.md

* fix conflicts

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 1544b20 commit 774a88c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt`.
* [#10725](https://github.com/cosmos/cosmos-sdk/pull/10725) populate `ctx.ConsensusParams` for begin/end blockers.

## [v0.44.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.5) - 2021-12-02
Expand Down
3 changes: 1 addition & 2 deletions math/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ func NewIntFromUint64(n uint64) Int {

// NewIntFromBigInt constructs Int from big.Int. If the provided big.Int is nil,
// it returns an empty instance. This function panics if the bit length is > 256.
// Note, the caller can safely mutate the argument after this function returns.
func NewIntFromBigInt(i *big.Int) Int {
if i == nil {
return Int{}
}

if bigIntOverflows(i) {
if i.BitLen() > maxBitLen {
panic("NewIntFromBigInt() out of bound")
}

Expand Down

0 comments on commit 774a88c

Please sign in to comment.