diff options
author | chriseth <c@ethdev.com> | 2015-07-14 23:43:13 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-07-14 23:43:13 +0800 |
commit | 3d03e85e4e39693e139aebe7205f176befa1a8bc (patch) | |
tree | 2a8ef3c32e67958438150bb66aa06c17939d9329 /Types.cpp | |
parent | da818b1acdd8f02fccd18779cfb0ac397d7e61b1 (diff) | |
download | dexon-solidity-3d03e85e4e39693e139aebe7205f176befa1a8bc.tar.gz dexon-solidity-3d03e85e4e39693e139aebe7205f176befa1a8bc.tar.zst dexon-solidity-3d03e85e4e39693e139aebe7205f176befa1a8bc.zip |
Check whether a literal is a valid literal before using it.
Fixes #2078
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -210,6 +210,8 @@ TypePointer Type::forLiteral(Literal const& _literal) case Token::FalseLiteral: return make_shared<BoolType>(); case Token::Number: + if (!IntegerConstantType::isValidLiteral(_literal)) + return TypePointer(); return make_shared<IntegerConstantType>(_literal); case Token::StringLiteral: return make_shared<StringLiteralType>(_literal); @@ -321,6 +323,19 @@ const MemberList IntegerType::AddressMemberList({ {"send", make_shared<FunctionType>(strings{"uint"}, strings{"bool"}, FunctionType::Location::Send)} }); +bool IntegerConstantType::isValidLiteral(const Literal& _literal) +{ + try + { + bigint x(_literal.getValue()); + } + catch (...) + { + return false; + } + return true; +} + IntegerConstantType::IntegerConstantType(Literal const& _literal) { m_value = bigint(_literal.getValue()); |