Changeset - r25045:308cc2b63552
[Not reviewed]
master
0 1 0
Patric Stout - 3 years ago 2021-03-12 08:26:03
truebrain@openttd.org
Fix #8851: don't allow infinite "exec" depth in script, but limit to 10 deep

This means if you execute a script from a script from a script, ..
for more than 10 times, it bails out now. This should be sufficient
for even the most complex scripts.
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -960,6 +960,11 @@ DEF_CONSOLE_CMD(ConExec)
 
		return true;
 
	}
 

	
 
	if (_script_current_depth == 11) {
 
		IConsoleError("Maximum 'exec' depth reached; script A is calling script B is calling script C ... more than 10 times.");
 
		return true;
 
	}
 

	
 
	_script_current_depth++;
 
	uint script_depth = _script_current_depth;
 

	
0 comments (0 inline, 0 general)