Skip to content

Commit 61e4295

Browse files
committed
simx86: unlink forward refs changing code (remove direct jumps)
So far NodeUnlinker only undid direct jumps for references *to* the node that was removed, but for forward references *from* the node it wasn't needed since the node would be deleted anyway. However with BreakNodeHook excluding the last instruction the linking jump instruction could still be kept and jump into a node that was also deleted. We must therefore also undo the jump for forward references! Fixes dosemu2#2708
1 parent bfb9225 commit 61e4295

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/base/emu-i386/simx86/trees.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,13 @@ static void unlinknode(TNode *G, linkdesc *T, char branch)
812812
dbug_printf("Unlinker: FW %c ref error\n", branch);
813813
leavedos_main(0x8111 + (branch == 'N'));
814814
}
815+
/* we must unlink the forward ref code since the node we linked to
816+
may also get deleted, and we may currently be executing G,
817+
where in BreakNodeHook the last instruction is excluded from
818+
tail code patching */
819+
IGen IG = (IGen){.op = JMP_LINK, .mode = MPATCH,
820+
.p0 = T->target, .p1 = G->key};
821+
CodeGen(G->addr + T->link, G->addr, &IG);
815822
T->ref = NULL;
816823
}
817824

0 commit comments

Comments
 (0)