diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-02 20:15:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 20:15:12 +0800 |
commit | 4220f01688e31c206c2b2ea472db42161d780a26 (patch) | |
tree | dcc58a450bc91b92a1b25973b8147435ba00b80c | |
parent | d85d0393cd0fdaedf4b9c065f3efbdf6435583a7 (diff) | |
parent | ba0015cf256b3cf5f90a0daf225072286d8d3da4 (diff) | |
download | dexon-solidity-4220f01688e31c206c2b2ea472db42161d780a26.tar dexon-solidity-4220f01688e31c206c2b2ea472db42161d780a26.tar.gz dexon-solidity-4220f01688e31c206c2b2ea472db42161d780a26.tar.bz2 dexon-solidity-4220f01688e31c206c2b2ea472db42161d780a26.tar.lz dexon-solidity-4220f01688e31c206c2b2ea472db42161d780a26.tar.xz dexon-solidity-4220f01688e31c206c2b2ea472db42161d780a26.tar.zst dexon-solidity-4220f01688e31c206c2b2ea472db42161d780a26.zip |
Merge pull request #1634 from ethereum/swap-assert
Warn early in a case of invalid swap
-rw-r--r-- | libevmasm/Instruction.h | 8 | ||||
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index a8a72234..be71a499 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -202,28 +202,28 @@ inline unsigned getSwapNumber(Instruction _inst) /// @returns the PUSH<_number> instruction inline Instruction pushInstruction(unsigned _number) { - assertThrow(1 <= _number && _number <= 32, InvalidOpcode, "Invalid PUSH instruction requested."); + assertThrow(1 <= _number && _number <= 32, InvalidOpcode, std::string("Invalid PUSH instruction requested (") + std::to_string(_number) + ")."); return Instruction(unsigned(Instruction::PUSH1) + _number - 1); } /// @returns the DUP<_number> instruction inline Instruction dupInstruction(unsigned _number) { - assertThrow(1 <= _number && _number <= 16, InvalidOpcode, "Invalid DUP instruction requested."); + assertThrow(1 <= _number && _number <= 16, InvalidOpcode, std::string("Invalid DUP instruction requested (") + std::to_string(_number) + ")."); return Instruction(unsigned(Instruction::DUP1) + _number - 1); } /// @returns the SWAP<_number> instruction inline Instruction swapInstruction(unsigned _number) { - assertThrow(1 <= _number && _number <= 16, InvalidOpcode, "Invalid SWAP instruction requested."); + assertThrow(1 <= _number && _number <= 16, InvalidOpcode, std::string("Invalid SWAP instruction requested (") + std::to_string(_number) + ")."); return Instruction(unsigned(Instruction::SWAP1) + _number - 1); } /// @returns the LOG<_number> instruction inline Instruction logInstruction(unsigned _number) { - assertThrow(_number <= 4, InvalidOpcode, "Invalid LOG instruction requested."); + assertThrow(_number <= 4, InvalidOpcode, std::string("Invalid LOG instruction requested (") + std::to_string(_number) + ")."); return Instruction(unsigned(Instruction::LOG0) + _number); } diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 9f019d27..42323abd 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -200,6 +200,7 @@ void CompilerUtils::encodeToMemory( // leave end_of_mem as dyn head pointer m_context << Instruction::DUP1 << u256(32) << Instruction::ADD; dynPointers++; + solAssert((argSize + dynPointers) < 16, "Stack too deep, try using less variables."); } else { |