From 6209e17c767544b19533341ab5ebb3f9b2faac6e Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <ryan.pavlik@collabora.com>
Date: Fri, 5 Apr 2019 17:21:35 -0500
Subject: [PATCH] st/oxr: Make verification macros confirm that the handle is
 alive.

---
 src/xrt/state_trackers/oxr/oxr_api_verify.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/xrt/state_trackers/oxr/oxr_api_verify.h b/src/xrt/state_trackers/oxr/oxr_api_verify.h
index ccb508d45..8da93b0f3 100644
--- a/src/xrt/state_trackers/oxr/oxr_api_verify.h
+++ b/src/xrt/state_trackers/oxr/oxr_api_verify.h
@@ -28,6 +28,13 @@ extern "C" {
 			                 "(" #thing " == %p)",                 \
 			                 (void*)new_thing);                    \
 		}                                                              \
+		if (new_thing->handle.state != OXR_HANDLE_STATE_LIVE) {        \
+			return oxr_error(log, XR_ERROR_HANDLE_INVALID,         \
+			                 " state == %s (" #thing " == %p)",    \
+			                 oxr_handle_state_to_string(           \
+			                     new_thing->handle.state),         \
+			                 (void*)new_thing);                    \
+		}                                                              \
 		oxr_log_set_instance(log, lookup);                             \
 	} while (0)
 
-- 
GitLab