Skip to content

Commit

Permalink
fix integer underflow (#374)
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign authored and gballet committed May 8, 2024
1 parent 077ad87 commit 8ac0570
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 8ac0570

Please sign in to comment.