Merge pull request #2834 from ethereum/fixTypeNameParsing

Crash fix, parseTypeName can return null.
This commit is contained in:
Alex Beregszaszi 2017-08-28 15:07:14 +01:00 committed by GitHub
commit 1beef38361
3 changed files with 18 additions and 1 deletions

View File

@ -5,6 +5,8 @@ Features:
* Type Checker: Warn on using literals as tight packing parameters in ``keccak256``, ``sha3``, ``sha256`` and ``ripemd160``.
Bugfixes:
* Parser: Crash fix related to parseTypeName.
### 0.4.16 (2017-08-24)

View File

@ -1244,7 +1244,10 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression(
{
expectToken(Token::New);
ASTPointer<TypeName> typeName(parseTypeName(false));
nodeFactory.setEndPositionFromNode(typeName);
if (typeName)
nodeFactory.setEndPositionFromNode(typeName);
else
nodeFactory.markEndPosition();
expression = nodeFactory.createNode<NewExpression>(typeName);
}
else

View File

@ -1602,6 +1602,18 @@ BOOST_AUTO_TEST_CASE(interface)
BOOST_CHECK(successParse(text));
}
BOOST_AUTO_TEST_CASE(newInvalidTypeName)
{
char const* text = R"(
contract C {
function f() {
new var;
}
}
)";
CHECK_PARSE_ERROR(text, "Expected explicit type name");
}
BOOST_AUTO_TEST_SUITE_END()
}