mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Improve abi decoding functions for arrays.
This commit is contained in:
@@ -1170,6 +1170,7 @@ string ABIFunctions::abiDecodingFunctionArrayAvailableLength(ArrayType const& _t
|
||||
solAssert(_type.dataStoredIn(DataLocation::Memory), "");
|
||||
if (_type.isByteArray())
|
||||
return abiDecodingFunctionByteArrayAvailableLength(_type, _fromMemory);
|
||||
solAssert(_type.calldataStride() > 0, "");
|
||||
|
||||
string functionName =
|
||||
"abi_decode_available_length_" +
|
||||
@@ -1186,11 +1187,11 @@ string ABIFunctions::abiDecodingFunctionArrayAvailableLength(ArrayType const& _t
|
||||
mstore(array, length)
|
||||
dst := add(array, 0x20)
|
||||
</dynamic>
|
||||
let src := offset
|
||||
if gt(add(src, mul(length, <stride>)), end) {
|
||||
let srcEnd := add(offset, mul(length, <stride>))
|
||||
if gt(srcEnd, end) {
|
||||
<revertInvalidStride>()
|
||||
}
|
||||
for { let i := 0 } lt(i, length) { i := add(i, 1) }
|
||||
for { let src := offset } lt(src, srcEnd) { src := add(src, <stride>) }
|
||||
{
|
||||
<?dynamicBase>
|
||||
let innerOffset := <load>(src)
|
||||
@@ -1201,7 +1202,6 @@ string ABIFunctions::abiDecodingFunctionArrayAvailableLength(ArrayType const& _t
|
||||
</dynamicBase>
|
||||
mstore(dst, <decodingFun>(elementPos, end))
|
||||
dst := add(dst, 0x20)
|
||||
src := add(src, <stride>)
|
||||
}
|
||||
}
|
||||
)");
|
||||
|
||||
Reference in New Issue
Block a user