mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 18:51:19 +00:00
Fix integer overflow (#10222)
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
This commit is contained in:
parent
1a0e16a48b
commit
72a2dd004b
@ -451,21 +451,15 @@ func (s *Store) applyWeightChanges(
|
||||
}
|
||||
s.proposerBoostLock.Unlock()
|
||||
|
||||
// A node's weight can not be negative but the delta can be negative.
|
||||
if nodeDelta < 0 {
|
||||
// A node's weight can not be negative but the delta can be negative.
|
||||
if int(n.weight)+nodeDelta < 0 {
|
||||
d := uint64(-nodeDelta)
|
||||
if n.weight < d {
|
||||
n.weight = 0
|
||||
} else {
|
||||
// Absolute value of node delta.
|
||||
d := nodeDelta
|
||||
if nodeDelta < 0 {
|
||||
d *= -1
|
||||
}
|
||||
// Subtract node's weight.
|
||||
n.weight -= uint64(d)
|
||||
n.weight -= d
|
||||
}
|
||||
} else {
|
||||
// Add node's weight.
|
||||
n.weight += uint64(nodeDelta)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user