@@ -351,9 +351,10 @@ library RLP {
351351 // Case: Long string (>55 bytes)
352352 uint256 lengthLength = prefix - SHORT_OFFSET - SHORT_THRESHOLD;
353353
354- require (itemLength > lengthLength && bytes1 (item.load (0 )) != 0x00 , RLPInvalidEncoding ());
354+ bytes32 lenChunk = item.load (1 );
355+ require (itemLength > lengthLength && bytes1 (lenChunk) != 0x00 , RLPInvalidEncoding ());
355356
356- uint256 len = uint256 (item. load ( 1 ) ) >> (256 - 8 * lengthLength);
357+ uint256 len = uint256 (lenChunk ) >> (256 - 8 * lengthLength);
357358 require (len > SHORT_THRESHOLD && itemLength > lengthLength + len, RLPInvalidEncoding ());
358359
359360 return (lengthLength + 1 , len, ItemType.Data);
@@ -369,10 +370,10 @@ library RLP {
369370 // Case: Long list
370371 uint256 lengthLength = prefix - LONG_OFFSET - SHORT_THRESHOLD;
371372
372- require (itemLength > lengthLength, RLPInvalidEncoding () );
373- require (bytes1 (item. load ( 0 )) != 0x00 );
373+ bytes32 lenChunk = item. load ( 1 );
374+ require (itemLength > lengthLength && bytes1 (lenChunk) != 0x00 , RLPInvalidEncoding () );
374375
375- uint256 len = uint256 (item. load ( 1 ) ) >> (256 - 8 * lengthLength);
376+ uint256 len = uint256 (lenChunk ) >> (256 - 8 * lengthLength);
376377 require (len > SHORT_THRESHOLD && itemLength > lengthLength + len, RLPInvalidEncoding ());
377378
378379 return (lengthLength + 1 , len, ItemType.List);
0 commit comments