Skip to content

Commit 40ce776

Browse files
committed
Merge remote-tracking branch 'upstream/master' into master
2 parents 39b89cb + 1368a42 commit 40ce776

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/biguint.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,10 @@ impl BigUint {
24232423
"The radix must be within 2...256"
24242424
);
24252425

2426+
if buf.is_empty() {
2427+
return Some(Zero::zero());
2428+
}
2429+
24262430
if radix != 256 && buf.iter().any(|&b| b >= radix as u8) {
24272431
return None;
24282432
}
@@ -2466,6 +2470,10 @@ impl BigUint {
24662470
"The radix must be within 2...256"
24672471
);
24682472

2473+
if buf.is_empty() {
2474+
return Some(Zero::zero());
2475+
}
2476+
24692477
if radix != 256 && buf.iter().any(|&b| b >= radix as u8) {
24702478
return None;
24712479
}

tests/biguint.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,8 @@ fn test_from_and_to_radix() {
15511551
}
15521552

15531553
assert!(BigUint::from_radix_le(&[10, 100, 10], 50).is_none());
1554+
assert_eq!(BigUint::from_radix_le(&[], 2), Some(BigUint::zero()));
1555+
assert_eq!(BigUint::from_radix_be(&[], 2), Some(BigUint::zero()));
15541556
}
15551557

15561558
#[test]

0 commit comments

Comments
 (0)