From 6cbbb73ca77a12402fcc043ef8239e88c2c75bb2 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Tue, 1 Nov 2016 16:24:15 -0700 Subject: [PATCH] Protect against NullReferenceException in Frame.StopStreams() --- .../Internal/Http/FrameOfT.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/FrameOfT.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/FrameOfT.cs index 6925c13bea..2d0eecad6e 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/FrameOfT.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/FrameOfT.cs @@ -159,11 +159,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http finally { _application.DisposeContext(context, _applicationException); + + // StopStreams should be called before the end of the "if (!_requestProcessingStopping)" block + // to ensure InitializeStreams has been called. + StopStreams(); } } - StopStreams(); - if (!_keepAlive) { // End the connection for non keep alive as data incoming may have been thrown off