Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
[serializer] Fixing issues in serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
wrwg authored and davidiw committed Sep 23, 2022
1 parent 0fe2e6c commit 566ace5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions language/move-bytecode-verifier/src/stack_usage_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,22 @@ impl<'a> StackUsageVerifier<'a> {
.at_code_offset(self.current_function(), block_start),
);
}
stack_size_increment -= num_pops;
stack_size_increment += num_pushes;
if let Some(new_incr) = u64::checked_sub(stack_size_increment, num_pops) {
stack_size_increment = new_incr
} else {
return Err(
PartialVMError::new(StatusCode::NEGATIVE_STACK_SIZE_WITHIN_BLOCK)
.at_code_offset(self.current_function(), block_start),
);
};
if let Some(new_incr) = u64::checked_add(stack_size_increment, num_pushes) {
stack_size_increment = new_incr
} else {
return Err(
PartialVMError::new(StatusCode::POSITIVE_STACK_SIZE_AT_BLOCK_END)
.at_code_offset(self.current_function(), block_start),
);
};
}

if stack_size_increment == 0 {
Expand Down

0 comments on commit 566ace5

Please sign in to comment.