Skip to content

Commit

Permalink
use checked addition to not panic in debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
Skgland committed Nov 7, 2023
1 parent 64ec072 commit 1fc48e9
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions idna/src/punycode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,7 @@ where
for c in input.clone() {
let c = c as u32;
if c < code_point {
delta += 1;
if delta == 0 {
return Err(()); // Overflow
}
delta = delta.checked_add(1).ok_or(())?;
}
if c == code_point {
// Represent delta as a generalized variable-length integer:
Expand Down

0 comments on commit 1fc48e9

Please sign in to comment.