aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorGav Wood <g@ethdev.com>2015-07-15 00:18:38 +0800
committerGav Wood <g@ethdev.com>2015-07-15 00:18:38 +0800
commitd747f34466ed6b3f3be0ea0c0d5278a7670e4d57 (patch)
tree0004c45f2757947323c857130c0d455147730750 /Types.cpp
parent08466095f719aa82ac7bc6827b4847f4699ff8d9 (diff)
parent3d03e85e4e39693e139aebe7205f176befa1a8bc (diff)
downloaddexon-solidity-d747f34466ed6b3f3be0ea0c0d5278a7670e4d57.tar
dexon-solidity-d747f34466ed6b3f3be0ea0c0d5278a7670e4d57.tar.gz
dexon-solidity-d747f34466ed6b3f3be0ea0c0d5278a7670e4d57.tar.bz2
dexon-solidity-d747f34466ed6b3f3be0ea0c0d5278a7670e4d57.tar.lz
dexon-solidity-d747f34466ed6b3f3be0ea0c0d5278a7670e4d57.tar.xz
dexon-solidity-d747f34466ed6b3f3be0ea0c0d5278a7670e4d57.tar.zst
dexon-solidity-d747f34466ed6b3f3be0ea0c0d5278a7670e4d57.zip
Merge pull request #2473 from chriseth/sol_fix_exponentialNotation
Check whether a literal is a valid literal before using it.
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 0ecb01d2..91ef16b5 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());