From 50f33bb98ef8707b6169460c22ebc5392e5815f1 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 18 Jun 2021 06:03:58 +0100 Subject: 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. --- Userland/Libraries/LibJS/Runtime/DatePrototype.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index acca8172c9..450c83244e 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -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(); -- cgit v1.2.3