Skip to content

Commit 5bcffbc

Browse files
committed
fix(azure): guard remaining nil derefs in loadbalancer, region, virtualnetwork
Extend the PR's nil-safety pass to three sites missed in the initial sweep: - GetIPOfLoadBalancerFrontendIPConfigWithClient: nil-check feConfig arg - GetAllAzureRegionsContextE: skip nil region in pager loop - GetVirtualNetworkSubnetsWithClient: skip nil element in subnet pager loop
1 parent 4677fb7 commit 5bcffbc

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

modules/azure/loadbalancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func ExtractLoadBalancerFrontendIPConfigNames(lb *armnetwork.LoadBalancer) []str
298298
// specified Frontend IP Configuration. For public IPs it requires a PublicIPAddressesClient
299299
// to resolve the public IP address.
300300
func GetIPOfLoadBalancerFrontendIPConfigWithClient(ctx context.Context, feConfig *armnetwork.FrontendIPConfiguration, pipClient *armnetwork.PublicIPAddressesClient, resourceGroupName string) (string, LoadBalancerIPType, error) {
301-
if feConfig.Properties == nil {
301+
if feConfig == nil || feConfig.Properties == nil {
302302
return "", NoIP, errors.New("frontend IP configuration has nil properties")
303303
}
304304

modules/azure/region.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,11 @@ func GetAllAzureRegionsContextE(t testing.TestingT, ctx context.Context, subscri
208208
}
209209

210210
for _, region := range page.Value {
211-
if region.Name != nil {
212-
regions = append(regions, *region.Name)
211+
if region == nil || region.Name == nil {
212+
continue
213213
}
214+
215+
regions = append(regions, *region.Name)
214216
}
215217
}
216218

modules/azure/virtualnetwork.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func GetVirtualNetworkSubnetsWithClient(ctx context.Context, client *armnetwork.
212212
}
213213

214214
for _, v := range page.Value {
215-
if v.Name == nil || v.Properties == nil || v.Properties.AddressPrefix == nil {
215+
if v == nil || v.Name == nil || v.Properties == nil || v.Properties.AddressPrefix == nil {
216216
continue
217217
}
218218

0 commit comments

Comments
 (0)