LibJS: Add missing exception check in Date.prototype.toJSON

It was missing an exception check on the call to to_primitive.
This fixes test/built-ins/Date/prototype/toJSON/called-as-function.js
from test262 crashing, but does not fix the test itself.
This commit is contained in:
Luke 2021-06-18 06:03:58 +01:00 committed by Andreas Kling
parent 35e7c44dd4
commit 50f33bb98e
Notes: sideshowbarker 2024-07-18 12:06:02 +09:00

View File

@ -846,6 +846,9 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_json)
return {};
auto time_value = Value(this_object).to_primitive(global_object, Value::PreferredType::Number);
if (vm.exception())
return {};
if (time_value.is_number() && !time_value.is_finite_number())
return js_null();