From 604ccc7a34489f48c10987d89c7e48ad22dec5dc Mon Sep 17 00:00:00 2001 From: Jason Francis Date: Tue, 28 Feb 2023 19:02:06 -0500 Subject: [PATCH] analysis: fix integer overflow in debug mode --- src/analysis/function_parameters.rs | 7 ++++++- src/analysis/functions.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/analysis/function_parameters.rs b/src/analysis/function_parameters.rs index 6f50866f0..6b6849c7f 100644 --- a/src/analysis/function_parameters.rs +++ b/src/analysis/function_parameters.rs @@ -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; diff --git a/src/analysis/functions.rs b/src/analysis/functions.rs index 62313bea1..4902207fe 100644 --- a/src/analysis/functions.rs +++ b/src/analysis/functions.rs @@ -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!(