diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-06-26 18:51:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-26 18:51:12 +0800 |
commit | a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365 (patch) | |
tree | b8e4cd938ada219278e3c0ea5509b4ef0a793bdd /libsolidity/codegen | |
parent | c328ab411b63fe182125e976eb05b4449fdd892d (diff) | |
parent | 5a75581f6643a229ab12a861d0b0663ea3e5158e (diff) | |
download | dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar.gz dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar.bz2 dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar.lz dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar.xz dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar.zst dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.zip |
Merge pull request #2460 from ethereum/disallowMultiModifier
Disallow invoking the same modifier multiple times.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/CompilerContext.cpp | 1 | ||||
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 1937b529..6875bda1 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -124,6 +124,7 @@ void CompilerContext::addVariable(VariableDeclaration const& _declaration, unsigned _offsetToCurrent) { solAssert(m_asm->deposit() >= 0 && unsigned(m_asm->deposit()) >= _offsetToCurrent, ""); + solAssert(m_localVariables.count(&_declaration) == 0, "Variable already present"); m_localVariables[&_declaration] = unsigned(m_asm->deposit()) - _offsetToCurrent; } diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index ace82ad4..977a2c7c 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -878,6 +878,7 @@ void ContractCompiler::appendModifierOrFunctionCode() solAssert(m_currentFunction, ""); unsigned stackSurplus = 0; Block const* codeBlock = nullptr; + vector<VariableDeclaration const*> addedVariables; m_modifierDepth++; @@ -901,6 +902,7 @@ void ContractCompiler::appendModifierOrFunctionCode() for (unsigned i = 0; i < modifier.parameters().size(); ++i) { m_context.addVariable(*modifier.parameters()[i]); + addedVariables.push_back(modifier.parameters()[i].get()); compileExpression( *modifierInvocation->arguments()[i], modifier.parameters()[i]->annotation().type @@ -927,6 +929,8 @@ void ContractCompiler::appendModifierOrFunctionCode() m_returnTags.pop_back(); CompilerUtils(m_context).popStackSlots(stackSurplus); + for (auto var: addedVariables) + m_context.removeVariable(*var); } m_modifierDepth--; } |