diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-07 13:57:02 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-07 18:11:59 +0200 |
commit | 845f2826aa0f558116bf57ade4ec29cded1fd185 (patch) | |
tree | a16cb34d8d14e009adeac8e279b4f7b9cbbe4c85 /Userland/Libraries/LibJS/Bytecode/Interpreter.cpp | |
parent | 9330163b0bb4ab30c53be41914bbf932dc3f5d2f (diff) | |
download | serenity-845f2826aa0f558116bf57ade4ec29cded1fd185.zip |
LibJS: Reset Bytecode::Interpreter's m_return_value when leaving run()
Otherwise it will cause complete unwind since all parent run() loops
will see the same m_return_value being non-empty and break out.
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode/Interpreter.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Interpreter.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 4d63cafeb7..ad09cc4fd3 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -77,16 +77,17 @@ Value Interpreter::run(Bytecode::Block const& block) m_register_windows.take_last(); - m_return_value = m_return_value.value_or(js_undefined()); + auto return_value = m_return_value.value_or(js_undefined()); + m_return_value = {}; // NOTE: The return value from a called function is put into $0 in the caller context. if (!m_register_windows.is_empty()) - m_register_windows.last()[0] = m_return_value; + m_register_windows.last()[0] = return_value; if (vm().call_stack().size() == 1) vm().pop_call_frame(); - return m_return_value; + return return_value; } } |