Skip to content

Commit 93cf012

Browse files
4creatorsjkotas
authored andcommitted
Fix invalid IntPtr == null comparisons, set strict mode for Roslyn (dotnet#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
1 parent 5d31194 commit 93cf012

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
<PropertyGroup>
33
<CL_MPCount>$(NumberOfCores)</CL_MPCount>
44
</PropertyGroup>
5+
<PropertyGroup>
6+
<!-- Enables Strict mode for Roslyn compiler -->
7+
<Features>strict</Features>
8+
</PropertyGroup>
59
</Project>

src/System.Private.CoreLib/src/System/StubHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ internal static unsafe IntPtr ConvertToNative(StringBuilder sb, IntPtr pNativeBu
200200

201201
internal static unsafe void ConvertToManaged(StringBuilder sb, IntPtr pNative)
202202
{
203-
if (pNative == null)
203+
if (pNative == IntPtr.Zero)
204204
return;
205205

206206
int nbBytes = StubHelpers.strlen((sbyte*)pNative);

0 commit comments

Comments
 (0)