Skip to content

Commit

Permalink
fix boundary check in PUSH
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed Nov 20, 2021
1 parent bcd6b71 commit ef6b8b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,11 @@ func makePush(size uint64, pushByteSize int) executionFunc {
for ; count < 31 && !scope.Contract.IsCode(chunk*31+count); count++ {
}
value[0] = byte(count)
copy(value[1:], scope.Contract.Code[chunk*31:(chunk+1)*31])
end := (chunk + 1) * 31
if end < uint64(len(scope.Contract.Code)) {
end = uint64(len(scope.Contract.Code))
}
copy(value[1:], scope.Contract.Code[chunk*31:end])
index := trieUtils.GetTreeKeyCodeChunk(scope.Contract.Address().Bytes(), uint256.NewInt(chunk))
interpreter.evm.TxContext.Accesses.TouchAddressAndChargeGas(index, nil)

Expand Down

0 comments on commit ef6b8b7

Please sign in to comment.