mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-22 16:37:28 +00:00
Fix dangerous parser use
Jean-Marc discovered a possible data loss caused by Parser::getChar(). This is now fixed, and Parser::getChar() is removed, since it is no longer needed and easy to use it in the wrong way.
This commit is contained in:
parent
7ac59e7b99
commit
5f3cd55f1d
@ -413,14 +413,6 @@ bool Parser::good()
|
||||
}
|
||||
|
||||
|
||||
char Parser::getChar()
|
||||
{
|
||||
if (!good())
|
||||
error("The input stream is not well...");
|
||||
return get_token().character();
|
||||
}
|
||||
|
||||
|
||||
bool Parser::hasOpt()
|
||||
{
|
||||
// An optional argument can occur in any of the following forms:
|
||||
|
@ -282,11 +282,6 @@ public:
|
||||
std::string verbatim_item();
|
||||
///
|
||||
std::string verbatimOption();
|
||||
/*!
|
||||
* Returns the character of the current token and increments
|
||||
* the token position.
|
||||
*/
|
||||
char getChar();
|
||||
///
|
||||
void error(std::string const & msg);
|
||||
/// The previous token.
|
||||
|
@ -2105,10 +2105,10 @@ void parse_macro(Parser & p, ostream & os, Context & context)
|
||||
|
||||
// followed by number?
|
||||
if (p.next_token().cat() == catOther) {
|
||||
char c = p.getChar();
|
||||
paramtext += c;
|
||||
string s = p.get_token().asInput();
|
||||
paramtext += s;
|
||||
// number = current arity + 1?
|
||||
if (c == arity + '0' + 1)
|
||||
if (s.size() == 1 && s[0] == arity + '0' + 1)
|
||||
++arity;
|
||||
else
|
||||
simple = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user