Skip to content

Commit 5b83ba6

Browse files
committed
fix: Fix RLPReader overflow bug
1 parent 4b07231 commit 5b83ba6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

contracts/lib/RLPReader.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,15 @@ library RLPReader {
333333
dest += WORD_SIZE;
334334
}
335335

336+
if (len == 0) return;
337+
336338
// left over bytes. Mask is used to remove unwanted bytes from the word
337339
uint mask = 256 ** (WORD_SIZE - len) - 1;
340+
338341
assembly {
339342
let srcpart := and(mload(src), not(mask)) // zero out src
340343
let destpart := and(mload(dest), mask) // retrieve the bytes
341344
mstore(dest, or(destpart, srcpart))
342345
}
343346
}
344-
}
347+
}

0 commit comments

Comments
 (0)