mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2770 from ethereum/recursionInAsm
Also prevent too much recursion in the assembly parser.
This commit is contained in:
@@ -64,25 +64,6 @@ private:
|
||||
SourceLocation m_location;
|
||||
};
|
||||
|
||||
/// Utility class that creates an error and throws an exception if the
|
||||
/// recursion depth is too deep.
|
||||
class Parser::RecursionGuard
|
||||
{
|
||||
public:
|
||||
explicit RecursionGuard(Parser& _parser):
|
||||
m_parser(_parser)
|
||||
{
|
||||
m_parser.increaseRecursionDepth();
|
||||
}
|
||||
~RecursionGuard()
|
||||
{
|
||||
m_parser.decreaseRecursionDepth();
|
||||
}
|
||||
|
||||
private:
|
||||
Parser& m_parser;
|
||||
};
|
||||
|
||||
ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner)
|
||||
{
|
||||
try
|
||||
@@ -1543,19 +1524,6 @@ ASTPointer<ParameterList> Parser::createEmptyParameterList()
|
||||
return nodeFactory.createNode<ParameterList>(vector<ASTPointer<VariableDeclaration>>());
|
||||
}
|
||||
|
||||
void Parser::increaseRecursionDepth()
|
||||
{
|
||||
m_recursionDepth++;
|
||||
if (m_recursionDepth >= 4096)
|
||||
fatalParserError("Maximum recursion depth reached during parsing.");
|
||||
}
|
||||
|
||||
void Parser::decreaseRecursionDepth()
|
||||
{
|
||||
solAssert(m_recursionDepth > 0, "");
|
||||
m_recursionDepth--;
|
||||
}
|
||||
|
||||
string Parser::currentTokenName()
|
||||
{
|
||||
Token::Value token = m_scanner->currentToken();
|
||||
|
||||
Reference in New Issue
Block a user