-
Notifications
You must be signed in to change notification settings - Fork 824
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 1005 panic sub overflow #1006
fix 1005 panic sub overflow #1006
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 PR! Looks good to me, one small point of feedback though
} | ||
|
||
let new_len = self.stack.len() - n; | ||
Ok(&self.stack[new_len..]) |
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.
Minor style feedback:
⛳️
let new_len = self.stack.len().checked_sub(n).ok_or( /* error code goes here */ );
// do other stuff here
I think this is a bit more explicit and concise!
This can be combined into a singe statement, but either style is fine.
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 agree with you, it would has been more clear in your way but the code will more complicated at the end because either:
wasmparser::primitives:BinaryReaderError
doesn't implementconvert::From
warning: unreachable expression
- unused varaible will be detected by the compiler somehow so we will need to rename
new_len
to_new_len
.
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.
Hmm, sorry I'm not following, I'll write out fully what I meant:
I think the entire function can just be:
pub fn peekn_extra(&self, n: usize) -> Result<&[(BasicValueEnum, ExtraInfo)], BinaryReaderError> {
let new_len = self.stack.len().checked_sub(n)
.ok_or(BinaryReaderError {
message: "invalid value stack",
offset: -1isize as usize,
});
Ok(&self.stack[new_len..])
}
Let me know if that doesn't make 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.
I've written the same and got some error but my bad i forgot to propagate the Err ;)
…entuzelo/wasmer into ventuzelo/fix-1005-panic-sub-overflow
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.
awesome, thanks!
bors r+ |
1006: fix 1005 panic sub overflow r=MarkMcCaskey a=pventuzelo # Description Fix issue #1005 # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Patrick Ventuzelo <[email protected]> Co-authored-by: Patrick Ventuzelo <[email protected]>
Build succeeded |
Description
Fix issue #1005
Review