Rewrite assembly slot offset for consistency (#5325)

This commit is contained in:
Hadrien Croubois
2025-05-07 21:54:42 +02:00
committed by GitHub
parent bdf8affec3
commit 633a1c85ca
8 changed files with 12 additions and 13 deletions

View File

@ -48,7 +48,7 @@ library Strings {
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(buffer, add(32, length))
ptr := add(add(buffer, 0x20), length)
}
while (true) {
ptr--;
@ -484,7 +484,7 @@ library Strings {
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(buffer, add(0x20, offset)))
value := mload(add(add(buffer, 0x20), offset))
}
}
}