use vm->callLevel to count recursive calls to VM_Call
Throw an error if vm->callLevel is set and VM_Free is called.
This commit is contained in:
parent
6c5211c0d3
commit
7a5243a3b2
4 changed files with 18 additions and 16 deletions
|
@ -608,6 +608,15 @@ VM_Free
|
|||
*/
|
||||
void VM_Free( vm_t *vm ) {
|
||||
|
||||
if(!vm) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(vm->callLevel) {
|
||||
Com_Error( ERR_FATAL, "VM_Free(%s) on running vm", vm->name );
|
||||
return;
|
||||
}
|
||||
|
||||
if(vm->destroy)
|
||||
vm->destroy(vm);
|
||||
|
||||
|
@ -635,13 +644,8 @@ void VM_Free( vm_t *vm ) {
|
|||
void VM_Clear(void) {
|
||||
int i;
|
||||
for (i=0;i<MAX_VM; i++) {
|
||||
if ( vmTable[i].dllHandle ) {
|
||||
Sys_UnloadDll( vmTable[i].dllHandle );
|
||||
}
|
||||
Com_Memset( &vmTable[i], 0, sizeof( vm_t ) );
|
||||
VM_Free(&vmTable[i]);
|
||||
}
|
||||
currentVM = NULL;
|
||||
lastVM = NULL;
|
||||
}
|
||||
|
||||
void *VM_ArgPtr( intptr_t intValue ) {
|
||||
|
@ -722,6 +726,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
|
|||
Com_Printf( "VM_Call( %d )\n", callnum );
|
||||
}
|
||||
|
||||
++vm->callLevel;
|
||||
// if we have a dll loaded, call it directly
|
||||
if ( vm->entryPoint ) {
|
||||
//rcg010207 - see dissertation at top of VM_DllSyscall() in this file.
|
||||
|
@ -765,6 +770,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
|
|||
r = VM_CallInterpreted( vm, &a.callnum );
|
||||
#endif
|
||||
}
|
||||
--vm->callLevel;
|
||||
|
||||
if ( oldVM != NULL )
|
||||
currentVM = oldVM;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue