aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-11-24 18:57:28 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-12-01 00:42:03 +0800
commit547deec4be55fc10b44de9ff92bb2d598d5b04f5 (patch)
tree14f73907ce89d7c4c54a091040cc08d0c88d5f5c
parent7959ee49beb664238e58dcb589f386b2dff7438c (diff)
downloaddexon-solidity-547deec4be55fc10b44de9ff92bb2d598d5b04f5.tar.gz
dexon-solidity-547deec4be55fc10b44de9ff92bb2d598d5b04f5.tar.zst
dexon-solidity-547deec4be55fc10b44de9ff92bb2d598d5b04f5.zip
codegen: clean any data from the input
-rw-r--r--docs/miscellaneous.rst3
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp4
-rw-r--r--test/libsolidity/Assembly.cpp2
3 files changed, 6 insertions, 3 deletions
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index 7e9cee44..251d77d2 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -111,6 +111,9 @@ value is considered ``true`` by ``JUMPI`` instruction, we do not clean
the boolean values before they are used as the condition for
``JUMPI``.
+In addition to the design principle above, the Solidity compiler
+cleans input data when it is loaded onto the stack.
+
Different types have different rules for cleaning up overflows:
+---------------+---------------+------------------+
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index ce5bb1d2..6763e995 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -925,8 +925,8 @@ unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCallda
if (leftAligned)
m_context << shiftFactor << Instruction::MUL;
}
- if (_fromCalldata && _type.category() == Type::Category::Bool)
- m_context << Instruction::ISZERO << Instruction::ISZERO;
+ if (_fromCalldata)
+ convertType(_type, _type, true);
return numBytes;
}
diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp
index cc77bd4c..ed92ca2b 100644
--- a/test/libsolidity/Assembly.cpp
+++ b/test/libsolidity/Assembly.cpp
@@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(location_test)
shared_ptr<string const> n = make_shared<string>("");
AssemblyItems items = compileContract(sourceCode);
vector<SourceLocation> locations =
- vector<SourceLocation>(16, SourceLocation(2, 75, n)) +
+ vector<SourceLocation>(18, SourceLocation(2, 75, n)) +
vector<SourceLocation>(27, SourceLocation(20, 72, n)) +
vector<SourceLocation>{SourceLocation(42, 51, n), SourceLocation(65, 67, n)} +
vector<SourceLocation>(2, SourceLocation(58, 67, n)) +