]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
use unsigned comparisons for most of the boundschecks in the vm
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 16 Apr 2013 21:57:17 +0000 (21:57 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 19 Apr 2013 09:39:29 +0000 (11:39 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11938 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=26678e90426687f151e496d496a8cc4957e0fcba

prvm_execprogram.h

index 8c6b0e47eb3e66b9c6bb183073f6c8c53717845b..9620daca72176be7c4c45717970c2e2114561a81 100644 (file)
                        case OP_STOREP_FLD:             // integers
                        case OP_STOREP_S:
                        case OP_STOREP_FNC:             // pointers
-                               if (OPB->_int < 0 || OPB->_int + 1 > prog->entityfieldsarea)
+                               if ((unsigned int)OPB->_int >= (unsigned int)prog->entityfieldsarea)
                                {
                                        PreError();
                                        prog->error_cmd("%s attempted to write to an out of bounds edict (%i)", prog->name, (int)OPB->_int);
                                break;
 
                        case OP_ADDRESS:
-                               if (OPA->edict < 0 || OPA->edict >= prog->max_edicts)
+                               if ((unsigned int)OPA->edict >= (unsigned int)prog->max_edicts)
                                {
                                        PreError();
                                        prog->error_cmd("%s Progs attempted to address an out of bounds edict number", prog->name);
                        case OP_LOAD_ENT:
                        case OP_LOAD_S:
                        case OP_LOAD_FNC:
-                               if (OPA->edict < 0 || OPA->edict >= prog->max_edicts)
+                               if ((unsigned int)OPA->edict >= (unsigned int)prog->max_edicts)
                                {
                                        PreError();
                                        prog->error_cmd("%s Progs attempted to read an out of bounds edict number", prog->name);
                                break;
 
                        case OP_LOAD_V:
-                               if (OPA->edict < 0 || OPA->edict >= prog->max_edicts)
+                               if ((unsigned int)OPA->edict >= (unsigned int)prog->max_edicts)
                                {
                                        PreError();
                                        prog->error_cmd("%s Progs attempted to read an out of bounds edict number", prog->name);