Skip to content

Commit

Permalink
Perform null check before accessing it (#16552)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Apr 2, 2022
1 parent 712b4c7 commit 6a87b55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
--->

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

## Version 4.16.0
* Added support for retrieving the state of packet capture even when the provisioning state of the packet capture was failure
Expand Down Expand Up @@ -69,7 +70,6 @@
- Also updated cmdlet to add the property for configuring ExclusionManagedRuleSet within Exclusions
- `New-AzApplicationGatewayFirewallPolicyExclusion`
* Bug Fix in Application Gateway Trusted Client Certificate cmdlets to load the entire cert chain from file.

## Version 4.12.0
* Support for Sku, ScaleUnits parameters of BastionHost resource.
- `New-AzBastion`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ public partial class AddAzureRmRouteConfigCommand : NetworkBaseCmdlet

public override void Execute()
{

// Routes
if (this.RouteTable.Routes == null)
{
this.RouteTable.Routes = new List<PSRoute>();
}

var existingRoute = this.RouteTable.Routes.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
if (existingRoute != null)
{
throw new ArgumentException("Route with the specified name already exists");
}

// Routes
if (this.RouteTable.Routes == null)
{
this.RouteTable.Routes = new List<PSRoute>();
}


var vRoutes = new PSRoute();

Expand Down

0 comments on commit 6a87b55

Please sign in to comment.