Skip to content

Commit

Permalink
Fix invalid IntPtr == null comparisons, set strict mode for Roslyn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
4creators committed Jul 29, 2018
1 parent 5d31194 commit de2c0f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Directory.Build.props
Expand Up @@ -2,4 +2,8 @@
<PropertyGroup>
<CL_MPCount>$(NumberOfCores)</CL_MPCount>
</PropertyGroup>
<PropertyGroup>
<!-- Enables Strict mode for Roslyn compiler -->
<Features>strict</Features>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/src/System/StubHelpers.cs
Expand Up @@ -200,7 +200,7 @@ internal static unsafe IntPtr ConvertToNative(StringBuilder sb, IntPtr pNativeBu

internal static unsafe void ConvertToManaged(StringBuilder sb, IntPtr pNative)
{
if (pNative == null)
if (pNative == IntPtr.Zero)
return;

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

0 comments on commit de2c0f5

Please sign in to comment.