Skip to content

Commit e16a7ef

Browse files
committed
core/vm: capped int pool
1 parent a816e75 commit e16a7ef

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/vm/intpool.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import "math/big"
2020

2121
var checkVal = big.NewInt(-42)
2222

23+
const poolLimit = 256
24+
2325
// intPool is a pool of big integers that
2426
// can be reused for all big.Int operations.
2527
type intPool struct {
@@ -37,6 +39,10 @@ func (p *intPool) get() *big.Int {
3739
return new(big.Int)
3840
}
3941
func (p *intPool) put(is ...*big.Int) {
42+
if len(p.pool.data) > poolLimit {
43+
return
44+
}
45+
4046
for _, i := range is {
4147
// verifyPool is a build flag. Pool verification makes sure the integrity
4248
// of the integer pool by comparing values to a default value.

0 commit comments

Comments
 (0)