Skip to content

Commit 44d9dae

Browse files
committed
Fix potential nullref in WindowsMixedRealityUtilities
1 parent c046ff1 commit 44d9dae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/Shared/WindowsMixedRealityUtilities.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
54
using System;
5+
6+
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
67
using System.Runtime.InteropServices;
78
#if WINDOWS_UWP
89
using Windows.Perception.Spatial;
@@ -64,7 +65,7 @@ public static SpatialCoordinateSystem SpatialCoordinateSystem
6465
{
6566
get
6667
{
67-
if (spatialCoordinateSystem == null && UtilitiesProvider != null)
68+
if (spatialCoordinateSystem == null && UtilitiesProvider != null && UtilitiesProvider.ISpatialCoordinateSystemPtr != IntPtr.Zero)
6869
{
6970
#if ENABLE_DOTNET
7071
spatialCoordinateSystem = GetSpatialCoordinateSystem(UtilitiesProvider.ISpatialCoordinateSystemPtr);
@@ -89,7 +90,7 @@ public static HolographicFrame CurrentHolographicFrame
8990
{
9091
get
9192
{
92-
if (UtilitiesProvider == null)
93+
if (UtilitiesProvider == null || UtilitiesProvider.IHolographicFramePtr == IntPtr.Zero)
9394
{
9495
return null;
9596
}
@@ -107,13 +108,13 @@ public static HolographicFrame CurrentHolographicFrame
107108
private static SpatialCoordinateSystem spatialCoordinateSystem = null;
108109
#endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
109110

110-
[System.Obsolete("Use the System.Numerics.Vector3 extension method ToUnityVector3 instead.")]
111+
[Obsolete("Use the System.Numerics.Vector3 extension method ToUnityVector3 instead.")]
111112
public static UnityEngine.Vector3 SystemVector3ToUnity(System.Numerics.Vector3 vector)
112113
{
113114
return vector.ToUnityVector3();
114115
}
115116

116-
[System.Obsolete("Use the System.Numerics.Quaternion extension method ToUnityQuaternion instead.")]
117+
[Obsolete("Use the System.Numerics.Quaternion extension method ToUnityQuaternion instead.")]
117118
public static UnityEngine.Quaternion SystemQuaternionToUnity(System.Numerics.Quaternion quaternion)
118119
{
119120
return quaternion.ToUnityQuaternion();

0 commit comments

Comments
 (0)