From 509e5a3045f2d165616d00d5c9b05863ba0883ef Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 28 Jan 2021 10:20:52 +0100 Subject: [PATCH] LibJS: Fix crash when printing error for missing class extends value prototype If it's missing we get an empty value, but we can't use that with to_string_without_side_effects() so we have to use undefined as the default. Fixes #5142. --- Userland/Libraries/LibJS/AST.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 3e327ac365..29e9a8327b 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -818,7 +818,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob Object* super_constructor_prototype = nullptr; if (!super_constructor.is_null()) { - auto super_constructor_prototype_value = super_constructor.as_object().get(vm.names.prototype); + auto super_constructor_prototype_value = super_constructor.as_object().get(vm.names.prototype).value_or(js_undefined()); if (interpreter.exception()) return {}; if (!super_constructor_prototype_value.is_object() && !super_constructor_prototype_value.is_null()) {