Skip to content

Commit

Permalink
Merge pull request #868 from eth-brownie/fix-memory-zerobytes
Browse files Browse the repository at this point in the history
fix: add zero-bytes when memory ends too soon
  • Loading branch information
iamdefinitelyahuman committed Nov 28, 2020
2 parents a18c42d + e7bd7e6 commit ac42bd8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion brownie/network/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,10 @@ def _step_external(
def _get_memory(step: Dict, idx: int) -> HexBytes:
offset = int(step["stack"][idx], 16)
length = int(step["stack"][idx - 1], 16)
return HexBytes("".join(step["memory"]))[offset : offset + length]
data = HexBytes("".join(step["memory"]))[offset : offset + length]
# append zero-bytes if allocated memory ends before `length` bytes
data = HexBytes(data + b"\x00" * (length - len(data)))
return data


def _get_last_map(address: EthAddress, sig: str) -> Dict:
Expand Down

0 comments on commit ac42bd8

Please sign in to comment.