File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ library BytesParsing {
7
7
8
8
error OutOfBounds (uint256 offset , uint256 length );
9
9
error LengthMismatch (uint256 encodedLength , uint256 expectedLength );
10
+ error InvalidBoolVal (uint8 val );
10
11
11
12
function checkBound (uint offset , uint length ) internal pure {
12
13
if (offset > length)
@@ -95,8 +96,15 @@ library BytesParsing {
95
96
bytes memory encoded ,
96
97
uint offset
97
98
) internal pure returns (bool , uint ) {
98
- (uint8 ret , uint nextOffset ) = asUint8 (encoded, offset);
99
- return (ret != 0 , nextOffset);
99
+ (uint8 val , uint nextOffset ) = asUint8 (encoded, offset);
100
+ if (val & 0xfe != 0 )
101
+ revert InvalidBoolVal (val);
102
+
103
+ bool ret;
104
+ assembly ("memory-safe" ) {
105
+ ret := val
106
+ }
107
+ return (ret, nextOffset);
100
108
}
101
109
102
110
function asBool (
You can’t perform that action at this time.
0 commit comments