Skip to content

Commit ecf933e

Browse files
Add comment
1 parent a875692 commit ecf933e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

azure-ipam/ipam.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error {
137137
}
138138
}
139139

140-
if gatewayIP != nil && len(*gatewayIP) > i {
140+
// Check gateway index before assigning to avoid index out of bounds exception and log warning for nil gateway
141+
if len(*gatewayIP) > i && (*gatewayIP)[i] != nil {
141142
ipConfig.Gateway = (*gatewayIP)[i]
142143
} else {
143144
p.logger.Warn("No gateway IP returned from CNS, setting to nil", zap.Any("gatewayIP", gatewayIP), zap.Int("index", i))

0 commit comments

Comments
 (0)