From 42dcd0ba2879ccb157fe3ec4cc6b16ea8ba53e69 Mon Sep 17 00:00:00 2001 From: Rob Ward Date: Thu, 1 Mar 2018 11:25:04 -0800 Subject: [PATCH] UrlHelperFactory.GetUrlHelper throws NullReferenceException when passed a null action context. This change validates the action context parameter. --- .../Routing/UrlHelperFactory.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs index 4fdf9daa3b..f9b8006850 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs @@ -15,6 +15,11 @@ namespace Microsoft.AspNetCore.Mvc.Routing /// public IUrlHelper GetUrlHelper(ActionContext context) { + if (context == null) + { + throw new ArgumentNullException(Resources.ArgumentCannotBeNullOrEmpty, (nameof(context))); + } + var httpContext = context.HttpContext; if (httpContext == null)