]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiApplication.cpp
Make LFUN_REPEAT more robust by limiting to 10000 iterations
[features.git] / src / frontends / qt4 / GuiApplication.cpp
index c27f4c87e3a032147b335bce36fba34158213922..3a0c6013b1f829158f04e5ab486ea7014a9ee9b4 100644 (file)
@@ -1858,8 +1858,15 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                string countstr;
                string rest = split(argument, countstr, ' ');
                int const count = convert<int>(countstr);
-               for (int i = 0; i < count; ++i)
-                       dispatch(lyxaction.lookupFunc(rest));
+               // an arbitrary number to limit number of iterations
+               int const max_iter = 10000;
+               if (count > max_iter) {
+                       dr.setMessage(bformat(_("Cannot iterate more than %1$d times"), max_iter));
+                       dr.setError(true);
+               } else {
+                       for (int i = 0; i < count; ++i)
+                               dispatch(lyxaction.lookupFunc(rest));
+               }
                break;
        }