diff --git a/ArrayUtils.cpp b/ArrayUtils.cpp index 397b098c4..79ea49535 100644 --- a/ArrayUtils.cpp +++ b/ArrayUtils.cpp @@ -465,12 +465,10 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType) const m_context << eth::Instruction::DUP2 << load; // stack: // check out-of-bounds access - m_context << eth::Instruction::DUP2 << eth::Instruction::LT; - eth::AssemblyItem legalAccess = m_context.appendConditionalJump(); - // out-of-bounds access throws exception (just STOP for now) - m_context << eth::Instruction::STOP; + m_context << eth::Instruction::DUP2 << eth::Instruction::LT << eth::Instruction::ISZERO; + // out-of-bounds access throws exception + m_context.appendConditionalJumpTo(m_context.errorTag()); - m_context << legalAccess; // stack: m_context << eth::Instruction::SWAP1; if (_arrayType.isDynamicallySized()) diff --git a/Compiler.cpp b/Compiler.cpp index 5e24aaaa2..93d786bed 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -194,7 +194,6 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract) } else m_context << eth::Instruction::STOP; // function not found - for (auto const& it: interfaceFunctions) { FunctionTypePointer const& functionType = it.second; diff --git a/CompilerContext.h b/CompilerContext.h index 7bc29de1a..573e0b576 100644 --- a/CompilerContext.h +++ b/CompilerContext.h @@ -98,6 +98,8 @@ public: eth::AssemblyItem appendJumpToNew() { return m_asm.appendJump().tag(); } /// Appends a JUMP to a tag already on the stack CompilerContext& appendJump(eth::AssemblyItem::JumpType _jumpType = eth::AssemblyItem::JumpType::Ordinary); + /// Returns an "ErrorTag" + eth::AssemblyItem errorTag() { return m_asm.errorTag(); } /// Appends a JUMP to a specific tag CompilerContext& appendJumpTo(eth::AssemblyItem const& _tag) { m_asm.appendJump(_tag); return *this; } /// Appends pushing of a new tag and @returns the new tag. diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 5a9782858..bb3260770 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -1106,8 +1106,11 @@ void ExpressionCompiler::appendExternalFunctionCall( m_context << eth::Instruction::CALLCODE; else m_context << eth::Instruction::CALL; - auto tag = m_context.appendConditionalJump(); - m_context << eth::Instruction::STOP << tag; // STOP if CALL leaves 0. + + //Propagate error condition (if CALL pushes 0 on stack). + m_context << eth::Instruction::ISZERO; + m_context.appendConditionalJumpTo(m_context.errorTag()); + if (_functionType.valueSet()) m_context << eth::Instruction::POP; if (_functionType.gasSet()) diff --git a/ExpressionCompiler.h b/ExpressionCompiler.h index 954e32c84..174e16d8d 100644 --- a/ExpressionCompiler.h +++ b/ExpressionCompiler.h @@ -98,10 +98,7 @@ private: void appendHighBitsCleanup(IntegerType const& _typeOnStack); /// Appends code to call a function of the given type with the given arguments. - void appendExternalFunctionCall( - FunctionType const& _functionType, - std::vector> const& _arguments - ); + void appendExternalFunctionCall(FunctionType const& _functionType, std::vector> const& _arguments); /// Appends code that evaluates the given arguments and moves the result to memory encoded as /// specified by the ABI. The memory offset is expected to be on the stack and is updated by /// this call. If @a _padToWordBoundaries is set to false, all values are concatenated without