-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential nil pointer dereference in x/distribution #5621
Comments
Indeed true, but when would a |
This behavior has been uncovered while updating our app to Cosmos SDK 0.38, mainly due to bad migrations management: the This seems like a corner case which should never happen (migrations should be executed correctly :) but an error would be better than a raw nil pointer dereference-induced |
I see. No harm in being extra safe 👌 |
@alexanderbez The type Dec struct {
i *big.Int
} |
I already knew that @alessio ;-) |
Before checking Dec's value, one has to ensure the internal big.Int pointer is not nil first. Closes: #5621
Summary of Bug
The
validateCommunityTax()
function implemented here accepts a variablei
of typeinterface{}
which is immediately converted to aDec
using a type assertion.Subsequential call to
Dec
methods could lead to a nil pointer dereference ifi
is nil.Version
Cosmos SDK v0.38
Steps to Reproduce
This Go playground reproduces the issue.
Possible fix
A possible fix could be checking for nil value after the type assertion.
For Admin Use
The text was updated successfully, but these errors were encountered: