diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 4edec1554..a105036f8 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -180,6 +180,9 @@ void CompilerUtils::encodeToMemory( t = t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType(); } + if (_givenTypes.empty()) + return; + // Stack during operation: // ... ... // The values dyn_head_i are added during the first loop and they point to the head part diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 74b07d4d8..c358a5192 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -299,9 +299,12 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac // Return tag is used to jump out of the function. eth::AssemblyItem returnTag = m_context.pushNewTag(); - // Parameter for calldataUnpacker - m_context << CompilerUtils::dataStartOffset; - appendCalldataUnpacker(functionType->parameterTypes()); + if (!functionType->parameterTypes().empty()) + { + // Parameter for calldataUnpacker + m_context << CompilerUtils::dataStartOffset; + appendCalldataUnpacker(functionType->parameterTypes()); + } m_context.appendJumpTo(m_context.functionEntryLabel(functionType->declaration())); m_context << returnTag; // Return tag and input parameters get consumed.