-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Resolve memory overflow when b256::TryFrom<Bytes>
is not 32 bytes
#6136
Conversation
test/src/in_language_tests/test_programs/primitive_conversions_b256_inline_tests/src/main.sw
Show resolved
Hide resolved
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.
I don't think left padding is the correct behavior. Converting less than 32 bytes to a b256
should fail.
You may argue this for u256
though I still think it's dubious to assume user intent there. But for b256
it's categorically erroneous.
LGTM but can you update the title and PR message to reflect the changes? |
b256::TryFrom<Bytes>
has less than 32 bytesb256::TryFrom<Bytes>
is not 32 bytes
Description
Currently, when calling the
TryFrom
implementation forb256
fromBytes
, if theBytes
has less than 32 bytes a memory overflow error will occur. If there is less than 32 bytes,None
is now returned.Example:
Closes #6129
Checklist
Breaking*
orNew Feature
labels where relevant.