support dynamic data return

This commit is contained in:
Ricardo Guilherme Schmidt 2017-11-09 13:05:57 -02:00
parent 451984b55c
commit e43d1c5d78

View File

@ -25,7 +25,7 @@ contract DelegatedCall {
(outDataPtr, outSize) = _delegatecall(inDataPtr, inSize);
_;
assembly {
return(0, outSize)
return(outDataPtr, outSize)
}
}
@ -56,16 +56,17 @@ contract DelegatedCall {
internal
returns(bytes32 outDataPtr, uint256 outSize)
{
outSize = 0x20;
address target = _getDelegatedContract();
outDataPtr = _malloc(outSize);
bool failed;
assembly {
failed := iszero(delegatecall(sub(gas, 10000), target, inDataPtr, inSize, outDataPtr, outSize))
failed := iszero(delegatecall(sub(gas, 10000), target, inDataPtr, inSize, 0, 0))
outSize := returndatasize
}
require(!failed);
outDataPtr = _malloc(outSize);
assembly {
returndatacopy(outDataPtr, 0, outSize)
}
assert(!failed);
}
}