From da93f5ad3aac83afeb249941e0ca9629b1903bfa Mon Sep 17 00:00:00 2001 From: Jacek Blaszczynski Date: Mon, 30 Jul 2018 02:56:32 +0200 Subject: [PATCH] Fix invalid IntPtr == null comparisons, set strict mode for Roslyn (dotnet/coreclr#19191) Issue reported in https://github.com/dotnet/corefx/issues/31456 Solution is to compare always against IntPtr.Zero and use Roslyn stric mode for reporting warnings for IntPtr == null comparisons Commit migrated from https://github.com/dotnet/coreclr/commit/93cf012db8396f5ea16f70b781a5de0d012fc65d --- src/coreclr/Directory.Build.props | 4 ++++ src/coreclr/src/System.Private.CoreLib/src/System/StubHelpers.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coreclr/Directory.Build.props b/src/coreclr/Directory.Build.props index 3efd9a3..2082362 100644 --- a/src/coreclr/Directory.Build.props +++ b/src/coreclr/Directory.Build.props @@ -2,4 +2,8 @@ $(NumberOfCores) + + + strict + diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/StubHelpers.cs b/src/coreclr/src/System.Private.CoreLib/src/System/StubHelpers.cs index 6d9e7a8..b8e34e0 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/StubHelpers.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/StubHelpers.cs @@ -200,7 +200,7 @@ namespace System.StubHelpers internal static unsafe void ConvertToManaged(StringBuilder sb, IntPtr pNative) { - if (pNative == null) + if (pNative == IntPtr.Zero) return; int nbBytes = StubHelpers.strlen((sbyte*)pNative); -- 2.7.4