Skip to content

Commit

Permalink
[fix]replacement the abs() with unsigned_abs()
Browse files Browse the repository at this point in the history
abs() may be lead to panic in the debug mode and optimized code will return i64::MIN without a panic. so need use unsigned_abs() in here
  • Loading branch information
maldiohead authored Jun 27, 2024
1 parent 35d0840 commit 455f1eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stacks-common/src/deps_common/bitcoin/blockdata/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn build_scriptint(n: i64) -> Vec<u8> {

let neg = n < 0;

let mut abs = n.abs() as usize;
let mut abs = n.unsigned_abs() as usize;
let mut v = Vec::with_capacity(size_of::<usize>() + 1);
while abs > 0xFF {
v.push((abs & 0xFF) as u8);
Expand Down

0 comments on commit 455f1eb

Please sign in to comment.