aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-07-14 23:43:13 +0800
committerchriseth <c@ethdev.com>2015-07-14 23:43:13 +0800
commit3d03e85e4e39693e139aebe7205f176befa1a8bc (patch)
tree2a8ef3c32e67958438150bb66aa06c17939d9329 /Types.cpp
parentda818b1acdd8f02fccd18779cfb0ac397d7e61b1 (diff)
downloaddexon-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.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Types.cpp b/Types.cpp
index 3ea9caa7..798092fc 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -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());