summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-12 09:26:03 +0100
committerPatric Stout <github@truebrain.nl>2021-03-13 10:01:05 +0100
commit5056e963bab9683656e07e527b339f370383fa77 (patch)
tree342089a9cc3fca2fa2673a6b2f0ccbbd78f08b39
parent8230cd009d1c8aeaa7b8ea353db2f94027b97eb7 (diff)
downloadopenttd-5056e963bab9683656e07e527b339f370383fa77.tar.xz
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.
-rw-r--r--src/console_cmds.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index f66cfa6b6..f50644cf5 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -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;