1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

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) :^(
This commit is contained in:
Ali Mohammad Pur 2021-05-18 00:21:00 +04:30 committed by Linus Groh
parent 35b3ae26ed
commit 29b193d25d

View file

@ -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;