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
Fix binary marshalling of zero value #253
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and for finding this bug! Looks good overall :3
decimal.go
Outdated
// Verify we have at least 4 bytes for the exponent. The GOB encoded value | ||
// can be empty. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just grammar thing. I think may/might
would suit better here than can
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, I fixed it.
decimal.go
Outdated
if len(data) < 5 { | ||
// Verify we have at least 4 bytes for the exponent. The GOB encoded value | ||
// can be empty. | ||
if len(data) < 4 { | ||
return fmt.Errorf("error decoding binary %v: expected at least 5 bytes, got %d", data, len(data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we change this error message to ...expected at least 4 bytes...
? :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, that makes a lot of sense ^^'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
It seems that the recent release has trouble to unmarshal the zero value of the Decimal struct because it is now checking for a correct size of the exponent plus the value while a nil big Int will be encoded with no byte.