summaryrefslogtreecommitdiff
path: root/src/command_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-01-29 13:56:05 +0000
committerMaxime Coste <mawww@kakoune.org>2017-01-29 13:56:05 +0000
commit2052b225d9438328b27acee35a54e3ce1a5ec43e (patch)
tree602414581d9839e3764748332165c41b2a90654f /src/command_manager.cc
parent753f3a50d10e43134ebeb52b3ec0a10b7ec2b80a (diff)
Detect too deep command call stack
Fixes #1163
Diffstat (limited to 'src/command_manager.cc')
-rw-r--r--src/command_manager.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index 6b79df3c..d8c5bc58 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -417,11 +417,18 @@ CommandManager::find_command(const Context& context, const String& name) const
void CommandManager::execute_single_command(CommandParameters params,
Context& context,
const ShellContext& shell_context,
- DisplayCoord pos) const
+ DisplayCoord pos)
{
if (params.empty())
return;
+ constexpr int max_command_depth = 100;
+ if (m_command_depth > max_command_depth)
+ throw runtime_error("maximum nested command depth hit");
+
+ ++m_command_depth;
+ auto pop_cmd = on_scope_end([this] { --m_command_depth; });
+
ParameterList param_view(params.begin()+1, params.end());
auto command_it = find_command(context, params[0]);
if (command_it == m_commands.end())