summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-06-02 18:11:48 +0430
committerAndreas Kling <kling@serenityos.org>2021-06-02 18:02:47 +0200
commitea7ba34a31b3ef9f3ef49bb77068ffdb0167497c (patch)
tree335dbadb86c57bab43efc37cbddc7fe59163544c /Userland/Libraries
parent87ff76bd57046ef9fb287c68b740fee6c601621a (diff)
downloadserenity-ea7ba34a31b3ef9f3ef49bb77068ffdb0167497c.zip
AK+LibWasm+LibJS: Disallow Variant.has() on types that aren't contained
Checking for this (and get()'ing it) is always invalid, so let's just disallow it. This also finds two bugs where the code is checking for types that can never actually be in the variant (which was actually a refactor artifact).
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Parser.cpp2
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp
index 33b7ae6c4c..c1a8051f94 100644
--- a/Userland/Libraries/LibJS/Parser.cpp
+++ b/Userland/Libraries/LibJS/Parser.cpp
@@ -1609,7 +1609,7 @@ NonnullRefPtr<VariableDeclaration> Parser::parse_variable_declaration(bool for_l
init = parse_expression(2);
} else if (!for_loop_variable_declaration && declaration_kind == DeclarationKind::Const) {
syntax_error("Missing initializer in 'const' variable declaration");
- } else if (target.has<BindingPattern>()) {
+ } else if (target.has<NonnullRefPtr<BindingPattern>>()) {
syntax_error("Missing initializer in destructuring assignment");
}
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp
index 120d2fb0f7..905159266e 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp
+++ b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp
@@ -482,12 +482,12 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
return;
}
auto element = table_instance->elements()[index.value()];
- if (!element.has_value() || !element->ref().has<FunctionAddress>()) {
+ if (!element.has_value() || !element->ref().has<Reference::Func>()) {
dbgln("LibWasm: call_indirect attempted with invalid address element (not a function)");
m_do_trap = true;
return;
}
- auto address = element->ref().get<FunctionAddress>();
+ auto address = element->ref().get<Reference::Func>().address;
dbgln_if(WASM_TRACE_DEBUG, "call_indirect({} -> {})", index.value(), address.value());
call_address(configuration, address);
return;