From ab137eafadbfadbb228da0c8d6fbd1472068d500 Mon Sep 17 00:00:00 2001 From: MariusVanDerWijden Date: Thu, 4 Sep 2025 21:22:30 +0200 Subject: [PATCH] core/txpool: add sanity overflow check --- core/txpool/legacypool/list.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/txpool/legacypool/list.go b/core/txpool/legacypool/list.go index 507c0b429a..e5c48d538d 100644 --- a/core/txpool/legacypool/list.go +++ b/core/txpool/legacypool/list.go @@ -331,7 +331,11 @@ func (l *list) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Transa if overflow { return false, nil } - l.totalcost.Add(l.totalcost, cost) + total, overflow := new(uint256.Int).AddOverflow(l.totalcost, cost) + if overflow { + return false, nil + } + l.totalcost = total // Otherwise overwrite the old transaction with the current one l.txs.Put(tx)