fix(staking): add missing iterator.Close() calls (#25649)

Co-authored-by: Alex | Cosmos Labs <alex@cosmoslabs.io>
This commit is contained in:
Jammy Arkens 2025-12-09 02:52:45 +08:00 committed by GitHub
parent 0cc7aea897
commit 7e9ad4f140
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -77,7 +77,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* (x/staking) [#25649](https://github.com/cosmos/cosmos-sdk/pull/25649) Add missing `defer iterator.Close()` calls in `IterateDelegatorRedelegations` and `GetRedelegations` to prevent resource leaks.
* (mempool) [#25563](https://github.com/cosmos/cosmos-sdk/pull/25563) Cleanup sender indices in case of tx replacement.
* (x/epochs) [#25425](https://github.com/cosmos/cosmos-sdk/pull/25425) Fix `InvokeSetHooks` being called with a nil keeper and `AppModule` containing a copy instead of a pointer (hooks set post creating the `AppModule` like with depinject didn't apply because it's a different instance).
* (client, client/rpc, x/auth/tx) [#24551](https://github.com/cosmos/cosmos-sdk/pull/24551) Handle cancellation properly when supplying context to client methods.

View File

@ -353,6 +353,7 @@ func (k Keeper) IterateDelegatorRedelegations(ctx context.Context, delegator sdk
if err != nil {
return err
}
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
red, err := types.UnmarshalRED(k.cdc, iterator.Value())
@ -560,6 +561,7 @@ func (k Keeper) GetRedelegations(ctx context.Context, delegator sdk.AccAddress,
if err != nil {
return nil, err
}
defer iterator.Close()
i := 0
for ; iterator.Valid() && i < int(maxRetrieve); iterator.Next() {