From 70abe569c3b23bb62e9adb76acd754425a0b3b38 Mon Sep 17 00:00:00 2001 From: Martin Potter Date: Mon, 20 Jul 2020 10:25:12 -0700 Subject: [PATCH] Add null checks to MobileAuthenticatedStream to avoid null reference exception When attached with the native debugger, it does not allow you to continue past the native signal raised due to the null refrence exception. --- .../System/Mono.Net.Security/MobileAuthenticatedStream.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs b/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs index 7e743dc3cca7..496a620dc1d6 100644 --- a/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs +++ b/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs @@ -725,6 +725,9 @@ internal AsyncOperationStatus ProcessHandshake (AsyncOperationStatus status, boo internal (int ret, bool wantMore) ProcessRead (BufferOffsetSize userBuffer) { lock (ioLock) { + if (xobileTlsContext == null) + return (0, false); + // This operates on the internal buffer and will never block. if (operation != Operation.Authenticated) throw GetInternalError (); @@ -740,6 +743,9 @@ internal AsyncOperationStatus ProcessHandshake (AsyncOperationStatus status, boo internal (int ret, bool wantMore) ProcessWrite (BufferOffsetSize userBuffer) { lock (ioLock) { + if (xobileTlsContext == null) + return (0, false); + // This operates on the internal buffer and will never block. if (operation != Operation.Authenticated) throw GetInternalError ();