diff --git a/boa/src/bigint.rs b/boa/src/bigint.rs index c6330d20ab..2e2bca1d58 100644 --- a/boa/src/bigint.rs +++ b/boa/src/bigint.rs @@ -169,6 +169,15 @@ impl JsBigInt { 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))) }