浏览代码

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) :^(
Ali Mohammad Pur 4 年之前
父节点
当前提交
29b193d25d
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp

+ 2 - 1
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;