Skip to content

Commit 0d24013

Browse files
committed
Using returndatasize through memory (revert)
1 parent 7c51578 commit 0d24013

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

contracts/libraries/MultiSend.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ contract MultiSend {
6262
success := delegatecall(gas(), to, data, dataLength, 0, 0)
6363
}
6464
if eq(success, 0) {
65-
returndatacopy(0, 0, returndatasize())
66-
revert(0, returndatasize())
65+
let errorLength := returndatasize()
66+
returndatacopy(0, 0, errorLength)
67+
revert(0, errorLength)
6768
}
6869
// Next entry starts at 85 byte + data length
6970
i := add(i, add(0x55, dataLength))

contracts/libraries/MultiSendCallOnly.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ contract MultiSendCallOnly {
5757
revert(0, 0)
5858
}
5959
if eq(success, 0) {
60-
returndatacopy(0, 0, returndatasize())
61-
revert(0, returndatasize())
60+
let errorLength := returndatasize()
61+
returndatacopy(0, 0, errorLength)
62+
revert(0, errorLength)
6263
}
6364
// Next entry starts at 85 byte + data length
6465
i := add(i, add(0x55, dataLength))

contracts/test/DelegateCaller.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ contract DelegateCaller {
1515
if (!success) {
1616
/* solhint-disable no-inline-assembly */
1717
assembly {
18-
returndatacopy(0, 0, returndatasize())
19-
revert(0, returndatasize())
18+
let length := returndatasize()
19+
returndatacopy(0, 0, length)
20+
revert(0, length)
2021
}
2122
/* solhint-enable no-inline-assembly */
2223
}

0 commit comments

Comments
 (0)