Skip to content

Commit db2235a

Browse files
committed
Wrap slice overflow in unchecked block
1 parent b66afa9 commit db2235a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

contracts/BytesLib.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ library BytesLib {
234234
pure
235235
returns (bytes memory)
236236
{
237-
require(_length + 31 >= _length, "slice_overflow");
237+
// We're using the unchecked block below because otherwise execution ends
238+
// with the native overflow error code.
239+
unchecked {
240+
require(_length + 31 >= _length, "slice_overflow");
241+
}
238242
require(_bytes.length >= _start + _length, "slice_outOfBounds");
239243

240244
bytes memory tempBytes;

0 commit comments

Comments
 (0)