fix invalid memory access

This commit is contained in:
r4 2021-12-28 13:39:59 +01:00
parent 22f71d7e56
commit 0d5313a063

2
ir.c
View File

@ -143,7 +143,7 @@ void optimize_ir(IRToks *v) {
case IRJmp: {
/* resolve jump chains (esp. produced by if-else-if... statements) */
size_t ja = i;
while (v->toks[ja].instr == IRJmp)
while (ja < v->len && v->toks[ja].instr == IRJmp)
ja = v->toks[ja].Jmp.iaddr;
v->toks[i].Jmp.iaddr = ja;
}