Skip to content

Commit

Permalink
fix integer underflow (ethereum#374)
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
  • Loading branch information
jsign committed Feb 15, 2024
1 parent 540fa4e commit 4767773
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,13 @@ func touchCodeChunksRangeOnReadAndChargeGas(contractAddr []byte, startPC, size u
return 0
}

// endPC is the last PC that must be touched.
endPC := startPC + size - 1
if startPC+size > codeLen {
endPC := startPC + size
if endPC > codeLen {
endPC = codeLen
}
if endPC > 0 {
endPC -= 1 // endPC is the last bytecode that will be touched.
}

var statelessGasCharged uint64
for chunkNumber := startPC / 31; chunkNumber <= endPC/31; chunkNumber++ {
Expand Down

0 comments on commit 4767773

Please sign in to comment.