From eb0a4bda942b104e59e99eb495b64f6e9dd398ca Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 22 Aug 2007 02:01:24 +0000 Subject: [PATCH] - 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 --- core/vm/sp_vm_basecontext.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/vm/sp_vm_basecontext.cpp b/core/vm/sp_vm_basecontext.cpp index 51351e461..898fae1a0 100644 --- a/core/vm/sp_vm_basecontext.cpp +++ b/core/vm/sp_vm_basecontext.cpp @@ -257,7 +257,7 @@ int BaseContext::Execute(uint32_t code_addr, cell_t *result) } 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; 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 (err == SP_ERROR_NONE) { - if ((ctx->sp - (cell_t)(pushcount * sizeof(cell_t))) != save_sp) + if (ctx->sp != save_sp) { g_DbgReporter.GenerateCodeError(this, code_addr, @@ -313,6 +313,9 @@ int BaseContext::Execute(uint32_t code_addr, cell_t *result) } ctx->n_idx = n_idx; + ctx->n_err = SP_ERROR_NONE; + m_MsgCache[0] = '\0'; + m_CustomMsg = false; return err; }