summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-06-19 02:03:37 +0100
committerLinus Groh <mail@linusgroh.de>2021-06-19 02:03:37 +0100
commitfba3c77a04f7549dedd0b0e61dcea51bf81e266c (patch)
treed5dcda3c5591c985c4979b00c101542a55ac7ae1 /Userland/Libraries
parent8e26c7a1dd770a830f510c91160af7cd79d71a9b (diff)
downloadserenity-fba3c77a04f7549dedd0b0e61dcea51bf81e266c.zip
LibJS: Add missing exception checks to Number() constructor
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
index ac4f7a1917..618777388f 100644
--- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
@@ -84,15 +84,26 @@ static Value get_value_from_constructor_argument(GlobalObject& global_object)
// 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value
Value NumberConstructor::call()
{
- return get_value_from_constructor_argument(global_object());
+ auto& vm = this->vm();
+ auto& global_object = this->global_object();
+
+ auto number = get_value_from_constructor_argument(global_object);
+ if (vm.exception())
+ return {};
+ return number;
}
// 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value
Value NumberConstructor::construct(Function&)
{
- auto number = get_value_from_constructor_argument(global_object());
+ auto& vm = this->vm();
+ auto& global_object = this->global_object();
+
+ auto number = get_value_from_constructor_argument(global_object);
+ if (vm.exception())
+ return {};
// FIXME: Use OrdinaryCreateFromConstructor(NewTarget, "%Number.prototype%")
- return NumberObject::create(global_object(), number.as_double());
+ return NumberObject::create(global_object, number.as_double());
}
// 21.1.2.2 Number.isFinite ( number ), https://tc39.es/ecma262/#sec-number.isfinite