Skip to content

Commit 83f954d

Browse files
authored
Add memory side effects notes when using function pointers (#5174)
1 parent a9161aa commit 83f954d

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

contracts/utils/Arrays.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ library Arrays {
2626
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
2727
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
2828
* consume more gas than is available in a block, leading to potential DoS.
29+
*
30+
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
2931
*/
3032
function sort(
3133
uint256[] memory array,
@@ -53,6 +55,8 @@ library Arrays {
5355
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
5456
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
5557
* consume more gas than is available in a block, leading to potential DoS.
58+
*
59+
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
5660
*/
5761
function sort(
5862
address[] memory array,
@@ -80,6 +84,8 @@ library Arrays {
8084
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
8185
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
8286
* consume more gas than is available in a block, leading to potential DoS.
87+
*
88+
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
8389
*/
8490
function sort(
8591
bytes32[] memory array,

contracts/utils/cryptography/MerkleProof.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import {Hashes} from "./Hashes.sol";
2020
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
2121
* against this attack out of the box.
2222
*
23+
* IMPORTANT: Consider memory side-effects when using custom hashing functions
24+
* that access memory in an unsafe way.
25+
*
2326
* NOTE: This library supports proof verification for merkle trees built using
2427
* custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
2528
* leaf inclusion in trees built using non-commutative hashing functions requires

scripts/generate/templates/Arrays.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const sort = type => `\
2626
* array. Using it in view functions that are executed through \`eth_call\` is safe, but one should be very careful
2727
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
2828
* consume more gas than is available in a block, leading to potential DoS.
29+
*
30+
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
2931
*/
3032
function sort(
3133
${type}[] memory array,

scripts/generate/templates/MerkleProof.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import {Hashes} from "./Hashes.sol";
2626
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
2727
* against this attack out of the box.
2828
*
29+
* IMPORTANT: Consider memory side-effects when using custom hashing functions
30+
* that access memory in an unsafe way.
31+
*
2932
* NOTE: This library supports proof verification for merkle trees built using
3033
* custom _commutative_ hashing functions (i.e. \`H(a, b) == H(b, a)\`). Proving
3134
* leaf inclusion in trees built using non-commutative hashing functions requires

0 commit comments

Comments
 (0)