From 2ef24a3daf58d186cbeb00c7d60e7150d70f6202 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sun, 27 Dec 2015 22:35:14 -0500 Subject: [PATCH] Prevent nested command invocations in command-prompt For example, running "devel/send-key SELECT" in command-prompt would blow up the stack by recursively calling submit() --- plugins/command-prompt.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/command-prompt.cpp b/plugins/command-prompt.cpp index 2ac4d3af9..dd3b59398 100644 --- a/plugins/command-prompt.cpp +++ b/plugins/command-prompt.cpp @@ -56,7 +56,7 @@ public: df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); } std::string getFocusString() { return "commandprompt"; } - viewscreen_commandpromptst(std::string entry):is_response(false) + viewscreen_commandpromptst(std::string entry):is_response(false), submitted(false) { show_fps=gps->display_frames; gps->display_frames=0; @@ -127,6 +127,7 @@ protected: std::list > responses; int cursor_pos; int history_idx; + bool submitted; bool is_response; bool show_fps; int frame; @@ -194,6 +195,9 @@ void viewscreen_commandpromptst::submit() Screen::dismiss(this); return; } + if(submitted) + return; + submitted = true; prompt_ostream out(this); Core::getInstance().runCommand(out, get_entry()); if(out.empty() && responses.empty())