# HG changeset patch # User William Astle # Date 1646866563 25200 # Node ID 65c2085e0398147a0714989fa49958b0b5e9ee26 # Parent 428039e88a0b33d7ff39f3d866c4fb53ef12de4a Don't rely on undefined memory before start of instab When encountering a symbol on a line by itself, cl->insn was used to index into the instab array. Unfortunately, in that case, cl->insn will be -1 which will refer to memory before the start of instab. Depending on the compiler and linker, that could be anything. This would only have a visible effect on the OS9 target which has separate data and code address counters. On other targets, the two counters are kept in sync. This patch should short circuit that unfortunate code issue. diff -r 428039e88a0b -r 65c2085e0398 lwasm/pass1.c --- a/lwasm/pass1.c Wed Feb 09 21:44:28 2022 -0700 +++ b/lwasm/pass1.c Wed Mar 09 15:56:03 2022 -0700 @@ -430,7 +430,7 @@ debug_message(as, 50, "Register symbol %s: %s", cl -> sym, lw_expr_print(cl -> addr)); // register symbol at line address - if (instab[cl -> insn].flags & lwasm_insn_setdata) + if ((cl -> insn >= 0) && (instab[cl -> insn].flags & lwasm_insn_setdata)) { if (!register_symbol(as, cl, cl -> sym, cl -> daddr, symbol_flag_none)) {