diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-06-08 02:36:42 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2016-10-20 07:03:09 +0800 |
commit | 33250eef9e3322a366a71fbd55df12e829d70726 (patch) | |
tree | 2fe209825b297ff29a72bb9a05b64e930cd25a48 | |
parent | 48f20289115183ce48bc2df8116069f7460fe9e8 (diff) | |
download | dexon-solidity-33250eef9e3322a366a71fbd55df12e829d70726.tar dexon-solidity-33250eef9e3322a366a71fbd55df12e829d70726.tar.gz dexon-solidity-33250eef9e3322a366a71fbd55df12e829d70726.tar.bz2 dexon-solidity-33250eef9e3322a366a71fbd55df12e829d70726.tar.lz dexon-solidity-33250eef9e3322a366a71fbd55df12e829d70726.tar.xz dexon-solidity-33250eef9e3322a366a71fbd55df12e829d70726.tar.zst dexon-solidity-33250eef9e3322a366a71fbd55df12e829d70726.zip |
Reject negative shifts within constants
-rw-r--r-- | libsolidity/ast/Types.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index a6c73953..3f13d62d 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -710,9 +710,11 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ using boost::multiprecision::pow; if (fractional) return TypePointer(); - else if (abs(other.m_value) > numeric_limits<uint32_t>::max()) + else if (other.m_value < 0) return TypePointer(); - uint32_t exponent = abs(other.m_value).numerator().convert_to<uint32_t>(); + else if (other.m_value > numeric_limits<uint32_t>::max()) + return TypePointer(); + uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>(); value = m_value.numerator() * pow(bigint(2), exponent); break; } @@ -721,9 +723,11 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ using boost::multiprecision::pow; if (fractional) return TypePointer(); - else if (abs(other.m_value) > numeric_limits<uint32_t>::max()) + else if (other.m_value < 0) return TypePointer(); - uint32_t exponent = abs(other.m_value).numerator().convert_to<uint32_t>(); + else if (other.m_value > numeric_limits<uint32_t>::max()) + return TypePointer(); + uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>(); value = rational(m_value.numerator() / pow(bigint(2), exponent), 1); break; } |