diff options
author | Matthew Olsson <matthewcolsson@gmail.com> | 2021-06-13 08:50:05 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-19 09:38:26 +0200 |
commit | 3ee627909affafdd8d51df8272e32a7d55f3ca9d (patch) | |
tree | 5b4f36becf801d1a1fdd4dbfe7dc144d2a20b76a | |
parent | ce04c2259f78341667a5a94d1e5b9725167047e2 (diff) | |
download | serenity-3ee627909affafdd8d51df8272e32a7d55f3ca9d.zip |
LibJS: Ensure GetBy{Id,Value} never load <empty> into the accumulator
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index d0959adc09..6dfe48a42e 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -151,7 +151,7 @@ void SetVariable::execute_impl(Bytecode::Interpreter& interpreter) const void GetById::execute_impl(Bytecode::Interpreter& interpreter) const { if (auto* object = interpreter.accumulator().to_object(interpreter.global_object())) - interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property)); + interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property)).value_or(js_undefined()); } void PutById::execute_impl(Bytecode::Interpreter& interpreter) const @@ -328,7 +328,7 @@ void GetByValue::execute_impl(Bytecode::Interpreter& interpreter) const auto property_key = interpreter.accumulator().to_property_key(interpreter.global_object()); if (interpreter.vm().exception()) return; - interpreter.accumulator() = object->get(property_key); + interpreter.accumulator() = object->get(property_key).value_or(js_undefined()); } } |