Fix revert with reason coming from a string variable

This commit is contained in:
Alex Beregszaszi
2018-05-09 17:53:17 +02:00
committed by chriseth
parent 868d449c38
commit c03a29dea8
4 changed files with 45 additions and 2 deletions
-1
View File
@@ -89,7 +89,6 @@ void CompilerUtils::revertWithStringData(Type const& _argumentType)
abiEncode({_argumentType.shared_from_this()}, {make_shared<ArrayType>(DataLocation::Memory, true)});
toSizeAfterFreeMemoryPointer();
m_context << Instruction::REVERT;
m_context.adjustStackOffset(_argumentType.sizeOnStack());
}
unsigned CompilerUtils::loadFromMemory(
@@ -933,7 +933,11 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
// condition was not met, flag an error
m_context.appendInvalid();
else if (arguments.size() > 1)
{
utils().revertWithStringData(*arguments.at(1)->annotation().type);
// Here, the argument is consumed, but in the other branch, it is still there.
m_context.adjustStackOffset(arguments.at(1)->annotation().type->sizeOnStack());
}
else
m_context.appendRevert();
// the success branch