From b595047fdfb26a450c87ef6a1b0dc66e67dae2a1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 19 Aug 2008 06:40:25 +0000 Subject: [PATCH] Fixed OP_SWITCH accidentally using the wrong address to get the pcode base (regression based on assumption of JitWriter::inbase). --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402464 --- sourcepawn/jit/x86/jit_x86.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sourcepawn/jit/x86/jit_x86.cpp b/sourcepawn/jit/x86/jit_x86.cpp index 70d7ff9b..1513bcda 100644 --- a/sourcepawn/jit/x86/jit_x86.cpp +++ b/sourcepawn/jit/x86/jit_x86.cpp @@ -1600,8 +1600,9 @@ inline void WriteOp_JsGeq(JitWriter *jit) inline void WriteOp_Switch(JitWriter *jit) { + CompData *data = (CompData *)jit->data; cell_t offs = jit->read_cell(); - cell_t *tbl = (cell_t *)((char *)jit->inbase + offs + sizeof(cell_t)); + cell_t *tbl = (cell_t *)((char *)data->plugin->pcode + offs + sizeof(cell_t)); struct casetbl { @@ -2436,6 +2437,12 @@ jitoffs_t RelocLookup(JitWriter *jit, cell_t pcode_offs, bool relative) /* Offset must always be 1)positive and 2)less than or equal to the codesize */ assert(pcode_offs >= 0 && (uint32_t)pcode_offs <= data->plugin->pcode_size); /* Do the lookup in the native dictionary. */ +#if defined _DEBUG + if (jit->outbase != NULL) + { + assert(*(jitoffs_t *)(data->rebase + pcode_offs) != NULL); + } +#endif return *(jitoffs_t *)(data->rebase + pcode_offs); } else