Changeset - r22392:1bc1eb28b781
[Not reviewed]
master
0 1 0
frosch - 8 years ago 2016-05-30 21:03:11
frosch@openttd.org
(svn r27594) -Fix [FS#6473]: [Script] Kill scripts, when a non-suspendable valuator call takes way too long.
1 file changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_list.cpp
Show inline comments
 
@@ -11,6 +11,7 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_list.hpp"
 
#include "script_controller.hpp"
 
#include "../../debug.h"
 
#include "../../script/squirrel.hpp"
 

	
 
@@ -905,6 +906,16 @@ SQInteger ScriptList::Valuate(HSQUIRRELV
 
			}
 
		}
 

	
 
		/* Kill the script when the valuator call takes way too long.
 
		 * Triggered by nesting valuators, which then take billions of iterations. */
 
		if (ScriptController::GetOpsTillSuspend() < -1000000) {
 
			/* See below for explanation. The extra pop is the return value. */
 
			sq_pop(vm, nparam + 4);
 

	
 
			ScriptObject::SetAllowDoCommand(backup_allow);
 
			return sq_throwerror(vm, "excessive CPU usage in valuator function");
 
		}
 

	
 
		/* Was something changed? */
 
		if (previous_modification_count != this->modifications) {
 
			/* See below for explanation. The extra pop is the return value. */
0 comments (0 inline, 0 general)