- fixed a bug where the stack was restored incorrectly when the VM was not capable of properly restoring the stack (i.e. when an error occurred)

- fixed re-entrancy bugs when a nested VM call on the same context threw an error

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401373
This commit is contained in:
David Anderson 2007-08-22 02:01:24 +00:00
parent b24a28d834
commit eb0a4bda94

View File

@ -257,7 +257,7 @@ int BaseContext::Execute(uint32_t code_addr, cell_t *result)
} }
ctx->pushcount = 0; ctx->pushcount = 0;
cell_t save_sp = ctx->sp; cell_t save_sp = ctx->sp + (pushcount * sizeof(cell_t));
cell_t save_hp = ctx->hp; cell_t save_hp = ctx->hp;
uint32_t n_idx = ctx->n_idx; uint32_t n_idx = ctx->n_idx;
@ -285,7 +285,7 @@ int BaseContext::Execute(uint32_t code_addr, cell_t *result)
#if defined SOURCEMOD_BUILD #if defined SOURCEMOD_BUILD
if (err == SP_ERROR_NONE) if (err == SP_ERROR_NONE)
{ {
if ((ctx->sp - (cell_t)(pushcount * sizeof(cell_t))) != save_sp) if (ctx->sp != save_sp)
{ {
g_DbgReporter.GenerateCodeError(this, g_DbgReporter.GenerateCodeError(this,
code_addr, code_addr,
@ -313,6 +313,9 @@ int BaseContext::Execute(uint32_t code_addr, cell_t *result)
} }
ctx->n_idx = n_idx; ctx->n_idx = n_idx;
ctx->n_err = SP_ERROR_NONE;
m_MsgCache[0] = '\0';
m_CustomMsg = false;
return err; return err;
} }