Skip to content

Commit

Permalink
analysis: fix integer overflow in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jf2048 committed Mar 1, 2023
1 parent 0d26845 commit 604ccc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/analysis/function_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ pub fn analyze(
}
};

if async_func && to_remove.contains(&(pos - correction_instance)) {
if async_func
&& pos
.checked_sub(correction_instance)
.map(|p| to_remove.contains(&p))
.unwrap_or(false)
{
add_rust_parameter = false;
}
let mut transfer = par.transfer;
Expand Down
7 changes: 6 additions & 1 deletion src/analysis/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,12 @@ fn analyze_function(
correction_instance = 1;
}

if r#async && to_remove.contains(&(pos - correction_instance)) {
if r#async
&& pos
.checked_sub(correction_instance)
.map(|p| to_remove.contains(&p))
.unwrap_or(false)
{
continue;
}
assert!(
Expand Down

0 comments on commit 604ccc7

Please sign in to comment.