diff options
author | chriseth <chris@ethereum.org> | 2017-06-23 23:20:07 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-06-28 23:55:49 +0800 |
commit | 168f64f4cb55a7055261a4c66ca54f496e96b503 (patch) | |
tree | ebad17e2b6450183c2ef4b6738f1faa169f2dd65 /libsolidity/codegen/ContractCompiler.cpp | |
parent | 46caff4597a1cafbafe0cbcc9fb7e7478dd2a0e3 (diff) | |
download | dexon-solidity-168f64f4cb55a7055261a4c66ca54f496e96b503.tar.gz dexon-solidity-168f64f4cb55a7055261a4c66ca54f496e96b503.tar.zst dexon-solidity-168f64f4cb55a7055261a4c66ca54f496e96b503.zip |
Fix negative stack size checks.
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 977a2c7c..61a90050 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -267,12 +267,16 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac m_context << notFound; if (fallback) { + m_context.setStackOffset(0); if (!fallback->isPayable()) appendCallValueCheck(); eth::AssemblyItem returnTag = m_context.pushNewTag(); fallback->accept(*this); m_context << returnTag; + m_context.adjustStackOffset( + CompilerUtils(m_context).sizeOnStack(FunctionType(*fallback).returnParameterTypes()) - 1 + ); appendReturnValuePacker(FunctionType(*fallback).returnParameterTypes(), _contract.isLibrary()); } else @@ -285,6 +289,7 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac CompilerContext::LocationSetter locationSetter(m_context, functionType->declaration()); m_context << callDataUnpackerEntryPoints.at(it.first); + m_context.setStackOffset(0); // We have to allow this for libraries, because value of the previous // call is still visible in the delegatecall. if (!functionType->isPayable() && !_contract.isLibrary()) @@ -295,6 +300,11 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac appendCalldataUnpacker(functionType->parameterTypes()); m_context.appendJumpTo(m_context.functionEntryLabel(functionType->declaration())); m_context << returnTag; + m_context.adjustStackOffset( + CompilerUtils(m_context).sizeOnStack(functionType->returnParameterTypes()) - + CompilerUtils(m_context).sizeOnStack(functionType->parameterTypes()) - + 1 + ); appendReturnValuePacker(functionType->returnParameterTypes(), _contract.isLibrary()); } } |