Browse Source

fix(boa): fixes panic on bigint size (#1415)

pull/1332/head
neeldug 3 years ago committed by GitHub
parent
commit
7fc78f6610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      boa/src/bigint.rs

9
boa/src/bigint.rs

@ -169,6 +169,15 @@ impl JsBigInt {
return Err(context.construct_range_error("BigInt negative exponent")); return Err(context.construct_range_error("BigInt negative exponent"));
}; };
let num_bits = (x.inner.bits() as f64
* y.to_f64().expect("Unable to convert from BigUInt to f64"))
.floor()
+ 1f64;
if num_bits > 1_000_000_000f64 {
return Err(context.construct_range_error("Maximum BigInt size exceeded"));
}
Ok(Self::new(x.inner.as_ref().clone().pow(y))) Ok(Self::new(x.inner.as_ref().clone().pow(y)))
} }

Loading…
Cancel
Save