Skip to content

Commit 6a87b55

Browse files
pregressmsJinLeiwyunchi-ms
authored
Perform null check before accessing it (#16552)
* Perform null check before accessing it Perform the null check on RouteTable.Routes before accessing it with SingleOrDefault. * Update ChangeLog.md * Update ChangeLog.md fix change log * Update ChangeLog.md Co-authored-by: Jin Lei <[email protected]> Co-authored-by: Yunchi Wang <[email protected]>
1 parent 712b4c7 commit 6a87b55

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Fixed `ArgumentNullException` in `Add-AzureRmRouteConfig` when `RouteTable.Routes` is null.
2223

2324
## Version 4.16.0
2425
* Added support for retrieving the state of packet capture even when the provisioning state of the packet capture was failure
@@ -69,7 +70,6 @@
6970
- Also updated cmdlet to add the property for configuring ExclusionManagedRuleSet within Exclusions
7071
- `New-AzApplicationGatewayFirewallPolicyExclusion`
7172
* Bug Fix in Application Gateway Trusted Client Certificate cmdlets to load the entire cert chain from file.
72-
7373
## Version 4.12.0
7474
* Support for Sku, ScaleUnits parameters of BastionHost resource.
7575
- `New-AzBastion`

src/Network/Network/Generated/RouteTable/Route/AddAzureRmRouteConfigCommand.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,19 @@ public partial class AddAzureRmRouteConfigCommand : NetworkBaseCmdlet
7878

7979
public override void Execute()
8080
{
81-
81+
// Routes
82+
if (this.RouteTable.Routes == null)
83+
{
84+
this.RouteTable.Routes = new List<PSRoute>();
85+
}
86+
8287
var existingRoute = this.RouteTable.Routes.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
8388
if (existingRoute != null)
8489
{
8590
throw new ArgumentException("Route with the specified name already exists");
8691
}
8792

88-
// Routes
89-
if (this.RouteTable.Routes == null)
90-
{
91-
this.RouteTable.Routes = new List<PSRoute>();
92-
}
93+
9394

9495
var vRoutes = new PSRoute();
9596

0 commit comments

Comments
 (0)