diff options
author | chriseth <chris@ethereum.org> | 2017-08-21 22:34:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-21 22:34:59 +0800 |
commit | 01b4bba0ed7544ed6f54f97dd5d5a3b0d397fbfa (patch) | |
tree | 577b2d76fbc0388954f69b750a50796f2ba17b63 /libsolidity | |
parent | fe25bcf350bfb65ddb69bc5e7d3f65dfa6d23fa7 (diff) | |
parent | 1be713acc7abc2f1d21d962e840b1e369d1d8ff6 (diff) | |
download | dexon-solidity-01b4bba0ed7544ed6f54f97dd5d5a3b0d397fbfa.tar.gz dexon-solidity-01b4bba0ed7544ed6f54f97dd5d5a3b0d397fbfa.tar.zst dexon-solidity-01b4bba0ed7544ed6f54f97dd5d5a3b0d397fbfa.zip |
Merge branch 'develop' into library-constructor
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 21 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmParser.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index 133f70b1..1dcc42b8 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -23,6 +23,9 @@ #include <libsolidity/inlineasm/AsmParser.h> #include <libsolidity/parsing/Scanner.h> #include <libsolidity/interface/ErrorReporter.h> + +#include <boost/algorithm/string.hpp> + #include <ctype.h> #include <algorithm> @@ -297,6 +300,8 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher) kind = LiteralKind::String; break; case Token::Number: + if (!isValidNumberLiteral(currentLiteral())) + fatalParserError("Invalid number literal."); kind = LiteralKind::Number; break; case Token::TrueLiteral: @@ -501,3 +506,19 @@ string Parser::expectAsmIdentifier() expectToken(Token::Identifier); return name; } + +bool Parser::isValidNumberLiteral(string const& _literal) +{ + try + { + u256(_literal); + } + catch (...) + { + return false; + } + if (boost::starts_with(_literal, "0x")) + return true; + else + return _literal.find_first_not_of("0123456789") == string::npos; +} diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h index 45708afd..a48a3393 100644 --- a/libsolidity/inlineasm/AsmParser.h +++ b/libsolidity/inlineasm/AsmParser.h @@ -75,6 +75,8 @@ protected: TypedName parseTypedName(); std::string expectAsmIdentifier(); + static bool isValidNumberLiteral(std::string const& _literal); + private: bool m_julia = false; }; |