From b7564630cddb388e843237e641d84365b2f6bb89 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 1 Feb 2017 12:20:47 +0000 Subject: [PATCH] Null pointer check fix --- Facepunch.Steamworks/Interop/Native.cs | 3 +++ Generator/CodeWriter/PlatformClass.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Facepunch.Steamworks/Interop/Native.cs b/Facepunch.Steamworks/Interop/Native.cs index 8cd5d5a..c59902f 100644 --- a/Facepunch.Steamworks/Interop/Native.cs +++ b/Facepunch.Steamworks/Interop/Native.cs @@ -47,6 +47,9 @@ namespace Facepunch.Steamworks.Interop FillInterfaces( steamworks, hUser, hPipe ); + if ( !user.IsValid ) + return false; + // Ensure that the user has logged into Steam. This will always return true if the game is launched // from Steam, but if Steam is at the login prompt when you run your game it will return false. if ( !user.BLoggedOn() ) diff --git a/Generator/CodeWriter/PlatformClass.cs b/Generator/CodeWriter/PlatformClass.cs index 14473ad..2409263 100644 --- a/Generator/CodeWriter/PlatformClass.cs +++ b/Generator/CodeWriter/PlatformClass.cs @@ -19,7 +19,7 @@ namespace Generator StartBlock( $"internal class {type} : Interface" ); { WriteLine( "internal IntPtr _ptr;" ); - WriteLine( "public bool IsValid { get{ return _ptr != null; } }" ); + WriteLine( "public bool IsValid { get{ return _ptr != IntPtr.Zero; } }" ); WriteLine(); WriteLine( "//" );