mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Make LFUN_REPEAT more robust by limiting to 10000 iterations
This commit is contained in:
parent
bc7704a78e
commit
4488c45d09
@ -3262,6 +3262,7 @@ void LyXAction::init()
|
|||||||
/*!
|
/*!
|
||||||
* \var lyx::FuncCode lyx::LFUN_REPEAT
|
* \var lyx::FuncCode lyx::LFUN_REPEAT
|
||||||
* \li Action: Repeat the given command.
|
* \li Action: Repeat the given command.
|
||||||
|
* \li Notion: fails when the repeat count is greater than 10000.
|
||||||
* \li Syntax: repeat <COUNT> <LFUN-COMMAND>
|
* \li Syntax: repeat <COUNT> <LFUN-COMMAND>
|
||||||
* \li Origin: Andre, 27 Oct 2003
|
* \li Origin: Andre, 27 Oct 2003
|
||||||
* \endvar
|
* \endvar
|
||||||
|
@ -1858,8 +1858,15 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
string countstr;
|
string countstr;
|
||||||
string rest = split(argument, countstr, ' ');
|
string rest = split(argument, countstr, ' ');
|
||||||
int const count = convert<int>(countstr);
|
int const count = convert<int>(countstr);
|
||||||
for (int i = 0; i < count; ++i)
|
// an arbitrary number to limit number of iterations
|
||||||
dispatch(lyxaction.lookupFunc(rest));
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user