Skip to content

Commit d88b6fe

Browse files
ernestognwAmxx
andcommitted
Add comment to readList and decodeList about aliasing (#6342)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
1 parent 4a8b122 commit d88b6fe

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

contracts/utils/RLP.sol

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,12 @@ library RLP {
346346
return string(readBytes(item));
347347
}
348348

349-
/// @dev Decodes an RLP encoded list into an array of RLP Items.
349+
/**
350+
* @dev Decodes an RLP encoded list in a memory slice into an array of RLP Items.
351+
*
352+
* NOTE: The returned array contains slice references into the original payload, not copied bytes. Any further
353+
* modification of the input buffer may cause the output result to become invalid.
354+
*/
350355
function readList(Memory.Slice item) internal pure returns (Memory.Slice[] memory list) {
351356
uint256 itemLength = item.length();
352357

@@ -413,7 +418,12 @@ library RLP {
413418
return readString(item.asSlice());
414419
}
415420

416-
/// @dev Decode an RLP encoded list from bytes. See {readList}
421+
/**
422+
* @dev Decode an RLP encoded list from bytes. See {readList}
423+
*
424+
* NOTE: The returned array contains slice references into the original payload, not copied bytes. Any further
425+
* modification of the input buffer may cause the output result to become invalid.
426+
*/
417427
function decodeList(bytes memory value) internal pure returns (Memory.Slice[] memory) {
418428
return readList(value.asSlice());
419429
}

0 commit comments

Comments
 (0)