Skip to content

Commit 8234108

Browse files
committed
Indexing into a vector past its end is UB.
1 parent 9d9ed3b commit 8234108

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/fizzy/execute.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ ExecutionResult execute(
593593
case Instr::end:
594594
{
595595
// End execution if it's a final end instruction.
596-
if (pc == &code.instructions[code.instructions.size()])
596+
if (pc == code.instructions.data() + code.instructions.size())
597597
goto end;
598598
break;
599599
}
@@ -1563,7 +1563,8 @@ ExecutionResult execute(
15631563
}
15641564

15651565
end:
1566-
assert(pc == &code.instructions[code.instructions.size()]); // End of code must be reached.
1566+
// End of code must be reached.
1567+
assert(pc == code.instructions.data() + code.instructions.size());
15671568
assert(stack.size() == instance.module->get_function_type(func_idx).outputs.size());
15681569

15691570
return stack.size() != 0 ? ExecutionResult{stack.top()} : Void;

0 commit comments

Comments
 (0)