1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:27:45 +00:00

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

View file

@ -846,6 +846,9 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_json)
return {}; return {};
auto time_value = Value(this_object).to_primitive(global_object, Value::PreferredType::Number); 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()) if (time_value.is_number() && !time_value.is_finite_number())
return js_null(); return js_null();