diff options
author | Tim Angus <tim@ngus.net> | 2007-07-15 14:15:41 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2007-07-15 14:15:41 +0000 |
commit | ffbf946dd63dccf0d6b6553c8bc1c9da4d3c89b3 (patch) | |
tree | 62b48381afabceca4c2aad7c39e0eeb51e328126 /src/qcommon/vm_interpreted.c | |
parent | 655d4c12eea45edf2041300eccace352a503b690 (diff) |
* Merge of ioq3-r1112
Diffstat (limited to 'src/qcommon/vm_interpreted.c')
-rw-r--r-- | src/qcommon/vm_interpreted.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/qcommon/vm_interpreted.c b/src/qcommon/vm_interpreted.c index 00aa4710..35096e5b 100644 --- a/src/qcommon/vm_interpreted.c +++ b/src/qcommon/vm_interpreted.c @@ -395,9 +395,8 @@ nextInstruction: r0 = ((int *)opStack)[0]; r1 = ((int *)opStack)[-1]; nextInstruction2: - opcode = codeImage[ programCounter++ ]; #ifdef DEBUG_VM - if ( (unsigned)programCounter > vm->codeLength ) { + if ( (unsigned)programCounter >= vm->codeLength ) { Com_Error( ERR_DROP, "VM pc out of range" ); } @@ -421,6 +420,7 @@ nextInstruction2: } profileSymbol->profileCount++; #endif + opcode = codeImage[ programCounter++ ]; switch ( opcode ) { #ifdef DEBUG_VM @@ -565,6 +565,8 @@ nextInstruction2: Com_Printf( "%s<--- %s\n", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) ); } #endif + } else if ( (unsigned)programCounter >= vm->codeLength ) { + Com_Error( ERR_DROP, "VM program counter out of range in OP_CALL" ); } else { programCounter = vm->instructionPointers[ programCounter ]; } @@ -620,6 +622,8 @@ nextInstruction2: // check for leaving the VM if ( programCounter == -1 ) { goto done; + } else if ( (unsigned)programCounter >= vm->codeLength ) { + Com_Error( ERR_DROP, "VM program counter out of range in OP_LEAVE" ); } goto nextInstruction; |