aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-05-23 16:40:09 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2017-05-23 16:40:09 +0800
commite16a7ef60ff1dedc3fe8f16e932466dc057787f7 (patch)
tree6c1b6f451594c659e239443b53479646545cdb33
parenta816e756625d39fc9b544f97dfa218d885996f33 (diff)
downloadgo-tangerine-e16a7ef60ff1dedc3fe8f16e932466dc057787f7.tar
go-tangerine-e16a7ef60ff1dedc3fe8f16e932466dc057787f7.tar.gz
go-tangerine-e16a7ef60ff1dedc3fe8f16e932466dc057787f7.tar.bz2
go-tangerine-e16a7ef60ff1dedc3fe8f16e932466dc057787f7.tar.lz
go-tangerine-e16a7ef60ff1dedc3fe8f16e932466dc057787f7.tar.xz
go-tangerine-e16a7ef60ff1dedc3fe8f16e932466dc057787f7.tar.zst
go-tangerine-e16a7ef60ff1dedc3fe8f16e932466dc057787f7.zip
core/vm: capped int pool
-rw-r--r--core/vm/intpool.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/vm/intpool.go b/core/vm/intpool.go
index 4f1228e14..384f5df59 100644
--- a/core/vm/intpool.go
+++ b/core/vm/intpool.go
@@ -20,6 +20,8 @@ import "math/big"
var checkVal = big.NewInt(-42)
+const poolLimit = 256
+
// intPool is a pool of big integers that
// can be reused for all big.Int operations.
type intPool struct {
@@ -37,6 +39,10 @@ func (p *intPool) get() *big.Int {
return new(big.Int)
}
func (p *intPool) put(is ...*big.Int) {
+ if len(p.pool.data) > poolLimit {
+ return
+ }
+
for _, i := range is {
// verifyPool is a build flag. Pool verification makes sure the integrity
// of the integer pool by comparing values to a default value.