From ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 4 Oct 2015 11:05:57 +0200 Subject: Encode storage items correctly for library calls. --- libsolidity/CompilerUtils.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libsolidity/CompilerUtils.cpp') diff --git a/libsolidity/CompilerUtils.cpp b/libsolidity/CompilerUtils.cpp index 583d267a..e1152202 100644 --- a/libsolidity/CompilerUtils.cpp +++ b/libsolidity/CompilerUtils.cpp @@ -189,7 +189,14 @@ void CompilerUtils::encodeToMemory( copyToStackTop(argSize - stackPos + dynPointers + 2, _givenTypes[i]->sizeOnStack()); solAssert(!!targetType, "Externalable type expected."); TypePointer type = targetType; - if ( + if (_givenTypes[i]->dataStoredIn(DataLocation::Storage) && targetType->isValueType()) + { + // special case: convert storage reference type to value type - this is only + // possible for library calls where we just forward the storage reference + solAssert(_encodeAsLibraryTypes, ""); + solAssert(_givenTypes[i]->sizeOnStack() == 1, ""); + } + else if ( _givenTypes[i]->dataStoredIn(DataLocation::Storage) || _givenTypes[i]->dataStoredIn(DataLocation::CallData) || _givenTypes[i]->category() == Type::Category::StringLiteral -- cgit