Skip to content

Commit

Permalink
Change the usage of the element in for loop to avoid memory aliasing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodeymo authored Oct 18, 2024
1 parent 0264584 commit d941249
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions chainio/clients/wallet/fireblocks_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func (t *fireblocksWallet) getAccount(ctx context.Context) (*fireblocks.VaultAcc
if err != nil {
return nil, fmt.Errorf("error listing vault accounts: %w", err)
}
for _, a := range accounts {
for i, a := range accounts {
if a.Name == t.vaultAccountName {
t.account = &a
t.account = &accounts[i]
break
}
}
Expand All @@ -121,11 +121,11 @@ func (f *fireblocksWallet) getWhitelistedAccount(
if err != nil {
return nil, fmt.Errorf("error listing external wallets: %w", err)
}
for _, a := range accounts {
for i, a := range accounts {
for _, asset := range a.Assets {
if asset.Address == address && asset.Status == "APPROVED" && asset.ID == assetID {
f.whitelistedAccounts[address] = &a
whitelistedAccount = &a
f.whitelistedAccounts[address] = &accounts[i]
whitelistedAccount = &accounts[i]
return whitelistedAccount, nil
}
}
Expand All @@ -152,11 +152,11 @@ func (t *fireblocksWallet) getWhitelistedContract(
if err != nil {
return nil, fmt.Errorf("error listing contracts: %w", err)
}
for _, c := range contracts {
for i_c, c := range contracts {
for _, a := range c.Assets {
if a.Address == address && a.Status == "APPROVED" && a.ID == assetID {
t.whitelistedContracts[address] = &c
contract = &c
t.whitelistedContracts[address] = &contracts[i_c]
contract = &contracts[i_c]
return contract, nil
}
}
Expand Down

0 comments on commit d941249

Please sign in to comment.