aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-10-24 17:54:51 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-11-17 08:46:45 +0800
commit1d5dd909b4ed8625330e9ec859e02dfd067f4006 (patch)
treef1302366463bb89248b632a6a947210e24af66cd
parent6ebc094474837d922ac00a92c54c903c5eb78585 (diff)
downloaddexon-solidity-1d5dd909b4ed8625330e9ec859e02dfd067f4006.tar.gz
dexon-solidity-1d5dd909b4ed8625330e9ec859e02dfd067f4006.tar.zst
dexon-solidity-1d5dd909b4ed8625330e9ec859e02dfd067f4006.zip
Do not try to display checksummed address for too-short/long address literals
-rw-r--r--libsolidity/analysis/TypeChecker.cpp4
-rw-r--r--libsolidity/ast/AST.cpp2
-rw-r--r--libsolidity/ast/AST.h2
3 files changed, 5 insertions, 3 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index fee60797..73047e76 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2000,8 +2000,8 @@ void TypeChecker::endVisit(Literal const& _literal)
m_errorReporter.warning(
_literal.location(),
"This looks like an address but has an invalid checksum. "
- "If this is not used as an address, please prepend '00'. "
- "Correct checksummed address: '" + _literal.getChecksummedAddress() + "'. "
+ "If this is not used as an address, please prepend '00'. " +
+ (!_literal.getChecksummedAddress().empty() ? "Correct checksummed address: '" + _literal.getChecksummedAddress() + "'. " : "") +
"For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals"
);
}
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 4911f161..62507093 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -587,5 +587,7 @@ bool Literal::passesAddressChecksum() const
std::string Literal::getChecksummedAddress() const
{
solAssert(isHexNumber(), "Expected hex number");
+ if (value().length != 42)
+ return string();
return dev::getChecksummedAddress(value());
}
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index 5d6763ca..feffde64 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -1613,7 +1613,7 @@ public:
bool looksLikeAddress() const;
/// @returns true if it passes the address checksum test.
bool passesAddressChecksum() const;
- /// @returns the checksummed version of an address
+ /// @returns the checksummed version of an address (or empty string if not valid)
std::string getChecksummedAddress() const;
private: