]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
progs: require the last statement to be GOTO, DONE or RETURN. Ensures the statement...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 19 Aug 2009 06:14:04 +0000 (06:14 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 19 Aug 2009 06:14:04 +0000 (06:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9125 d7cf8633-e32d-0410-b094-e92efae38249

prvm_edict.c

index 5da0a8fbd6adaf0a0e34050bd70d2274aaff5166..b5120522b6321700f0aa305e969f82e34dc318c8 100644 (file)
@@ -1920,6 +1920,20 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required
                        break;
                }
        }
+       if(prog->progs->numstatements < 1)
+       {
+               PRVM_ERROR("PRVM_LoadProgs: empty program in %s", PRVM_NAME);
+       }
+       else switch(prog->statements[prog->progs->numstatements - 1].op)
+       {
+               case OP_RETURN:
+               case OP_GOTO:
+               case OP_DONE:
+                       break;
+               default:
+                       PRVM_ERROR("PRVM_LoadProgs: program may fall off the edge (does not end with RETURN, GOTO or DONE) in %s", PRVM_NAME);
+                       break;
+       }
 
        PRVM_LoadLNO(filename);