- 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)
authorDavid Anderson <dvander@alliedmods.net>
Wed Aug 22 02:01:24 2007 +0000 (2007-08-22)
changeset 13670253af5c3bee
parent 1366 c1d3a4831ef9
child 1368 4ae6a5174091
- 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
core/vm/sp_vm_basecontext.cpp
     1.1 --- a/core/vm/sp_vm_basecontext.cpp	Wed Aug 22 01:19:10 2007 +0000
     1.2 +++ b/core/vm/sp_vm_basecontext.cpp	Wed Aug 22 02:01:24 2007 +0000
     1.3 @@ -257,7 +257,7 @@
     1.4  	}
     1.5  	ctx->pushcount = 0;
     1.6  
     1.7 -	cell_t save_sp = ctx->sp;
     1.8 +	cell_t save_sp = ctx->sp + (pushcount * sizeof(cell_t));
     1.9  	cell_t save_hp = ctx->hp;
    1.10  	uint32_t n_idx = ctx->n_idx;
    1.11  
    1.12 @@ -285,7 +285,7 @@
    1.13  #if defined SOURCEMOD_BUILD
    1.14  	if (err == SP_ERROR_NONE)
    1.15  	{
    1.16 -		if ((ctx->sp - (cell_t)(pushcount * sizeof(cell_t))) != save_sp)
    1.17 +		if (ctx->sp != save_sp)
    1.18  		{
    1.19  			g_DbgReporter.GenerateCodeError(this,
    1.20  				code_addr,
    1.21 @@ -313,6 +313,9 @@
    1.22  	}
    1.23  
    1.24  	ctx->n_idx = n_idx;
    1.25 +	ctx->n_err = SP_ERROR_NONE;
    1.26 +	m_MsgCache[0] = '\0';
    1.27 +	m_CustomMsg = false;
    1.28  
    1.29  	return err;
    1.30  }