diff options
Diffstat (limited to 'Libraries/LibJS/Runtime/Value.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/Value.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/Value.cpp b/Libraries/LibJS/Runtime/Value.cpp index 80917df5d5..9f248829a3 100644 --- a/Libraries/LibJS/Runtime/Value.cpp +++ b/Libraries/LibJS/Runtime/Value.cpp @@ -274,6 +274,10 @@ i32 Value::to_i32(Interpreter& interpreter) const auto number = to_number(interpreter); if (interpreter.exception()) return 0; + if (number.is_nan()) + return 0; + // FIXME: What about infinity though - that's UB... + // Maybe NumericLimits<i32>::max() for +Infinity and NumericLimits<i32>::min() for -Infinity? return number.as_i32(); } |