Skip to content

Commit e470a89

Browse files
authored
Fix zero-length slice taint bug (#43)
1 parent 889455e commit e470a89

File tree

3 files changed

+5860
-21
lines changed

3 files changed

+5860
-21
lines changed

contracts/BytesLib.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ library BytesLib {
284284
//if we want a zero-length slice let's just return a zero-length array
285285
default {
286286
tempBytes := mload(0x40)
287+
//zero out the 32 bytes slice we are about to return
288+
//we need to do it because Solidity does not garbage collect
289+
mstore(tempBytes, 0)
287290

288291
mstore(0x40, add(tempBytes, 0x20))
289292
}

0 commit comments

Comments
 (0)