diff options
author | Luke <luke.wilde@live.co.uk> | 2021-06-18 06:03:58 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-18 10:21:29 +0200 |
commit | 50f33bb98ef8707b6169460c22ebc5392e5815f1 (patch) | |
tree | 5bf1cf3043406a33a2b2d4d36fd7633aaec770a9 | |
parent | 35e7c44dd40500984f83ef0feb9cffac71d0b6d5 (diff) | |
download | serenity-50f33bb98ef8707b6169460c22ebc5392e5815f1.zip |
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.
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/DatePrototype.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
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(); |