Skip to content

Commit

Permalink
fix(math): fix panic in .Size() (#17480)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Aug 21, 2023
1 parent c94ce04 commit 1089f71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions math/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ Ref: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.j

# Changelog

## [math/v1.1.0](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.1.0) - 2023-08-18
## [math/v1.1.1](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.1.1) - 2023-08-21

### Bug Fixes

* [#17480](https://github.com/cosmos/cosmos-sdk/pull/17480) Fix panic when calling `.Size()` on a nil `math.Int` value.

## [math/v1.1.0](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.1.0) - 2023-08-19

### Features

Expand All @@ -48,7 +54,7 @@ Ref: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.j
### Bug Fixes

* [#17352](https://github.com/cosmos/cosmos-sdk/pull/17352) Ensure that modifying the argument to `NewIntFromBigInt` doesn't mutate the returned value.
* [#16266](https://github.com/cosmos/cosmos-sdk/pull/16266) fix: legacy dec power mut zero exponent precision.
* [#16266](https://github.com/cosmos/cosmos-sdk/pull/16266) Fix legacy dec power mut zero exponent precision.

## [math/v1.0.1](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.0.1) - 2023-05-15

Expand Down
4 changes: 4 additions & 0 deletions math/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ var (
)

func (i *Int) Size() (size int) {
if i == nil || i.i == nil {
return 1
}

sign := i.Sign()
if sign == 0 { // It is zero.
// log*(0) is undefined hence return early.
Expand Down
1 change: 1 addition & 0 deletions math/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ var sizeTests = []struct {
s string
want int
}{
{"", 1},
{"0", 1},
{"-0", 1},
{"-10", 3},
Expand Down

0 comments on commit 1089f71

Please sign in to comment.