From 185ad000bbf1e11b8573fed14581e18c71f9d104 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Thu, 12 May 2016 15:43:29 -0700 Subject: [PATCH] Prevent NullReferenceException in KestrelThread.OnStopRude - UvMemory.FromIntPtr looks up a weak reference so we need to null check. --- .../Infrastructure/KestrelThread.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelThread.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelThread.cs index 20183d92da..b176cfa697 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelThread.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/KestrelThread.cs @@ -132,7 +132,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel var handle = UvMemory.FromIntPtr(ptr); if (handle != _post) { - handle.Dispose(); + // handle can be null because UvMemory.FromIntPtr looks up a weak reference + handle?.Dispose(); } });