Skip to content

Commit

Permalink
Fix underflow introduced in memorysafety#1007
Browse files Browse the repository at this point in the history
`max` can be 0 and subtracting 1 causes underflow
  • Loading branch information
Frank Bossen committed May 8, 2024
1 parent ab6f6cf commit 35ea4f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fn read_tx_tree(
fn neg_deinterleave(diff: u8, r#ref: u8, max: u8) -> u8 {
if r#ref == 0 {
diff
} else if r#ref >= max - 1 {
} else if r#ref + 1 >= max {
max - diff - 1
} else if 2 * r#ref < max {
if diff <= 2 * r#ref {
Expand Down

0 comments on commit 35ea4f3

Please sign in to comment.