mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
fix: Prevent panic by Number::modulo (#773)
In Number::modulo, it calls Number::ints_to_bigint, which could panic. The reason is that calling .to_integer() isn't enough to guarantee that .to_bigint_owned() will return Some, but Number::ints_to_bigint assumes it will and calls unwrap(). In particular, it might be that it's a float corresponding to an integer that's larger than F64_SAFE_INTEGER. The fix is to not call Number::ints_to_bigint (and indeed to delete that entire function, which is only used in this one place), and instead only call unwrap when Some is returned.
This commit is contained in:
@@ -62,3 +62,12 @@ cases:
|
||||
x = 1 % 1.1
|
||||
query: data.test
|
||||
error: modulo on floating-point number
|
||||
|
||||
- note: integral float too large to convert
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = 100000000000000000e-1 % 2
|
||||
query: data.test
|
||||
error: modulo on floating-point number
|
||||
|
||||
Reference in New Issue
Block a user