diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-05-18 00:21:00 +0430 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-21 00:15:23 +0100 |
commit | 29b193d25d6effa2127b57d291c5350b2bd8a67b (patch) | |
tree | 8e8fb42acc3a7220c9b14d53a5db257861d8cfeb | |
parent | 35b3ae26ede410531db9ff06026662dadb61371d (diff) | |
download | serenity-29b193d25d6effa2127b57d291c5350b2bd8a67b.zip |
LibWasm: Resolve labels starting from the top of the stack
Otherwise "label index 0" would be the first ever created label, not the
last one (as the spec wants) :^(
-rw-r--r-- | Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp index ecc0bfd555..bc7e6c1f42 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp @@ -11,7 +11,8 @@ namespace Wasm { Optional<Label> Configuration::nth_label(size_t i) { - for (auto& entry : m_stack.entries()) { + for (size_t index = m_stack.size(); index > 0; --index) { + auto& entry = m_stack.entries()[index - 1]; if (auto ptr = entry.get_pointer<NonnullOwnPtr<Label>>()) { if (i == 0) return **ptr; |