st/oxr: Fix possible null dereference.

Found by clang-tidy.
This commit is contained in:
Ryan Pavlik 2019-08-16 17:02:38 -05:00
parent c8776a8b0d
commit 0088c6cb6e

View file

@ -607,17 +607,19 @@ oxr_session_create(struct oxr_logger *log,
const XrSessionCreateInfo *createInfo, const XrSessionCreateInfo *createInfo,
struct oxr_session **out_session) struct oxr_session **out_session)
{ {
struct oxr_session *sess; struct oxr_session *sess = NULL;
/* Try allocating and populating. */ /* Try allocating and populating. */
XrResult ret = oxr_session_create_impl(log, sys, createInfo, &sess); XrResult ret = oxr_session_create_impl(log, sys, createInfo, &sess);
if (ret != XR_SUCCESS) { if (ret != XR_SUCCESS) {
/* clean up allocation first */ if (sess != NULL) {
XrResult cleanup_result = /* clean up allocation first */
oxr_handle_destroy(log, &sess->handle); XrResult cleanup_result =
assert(cleanup_result == XR_SUCCESS); oxr_handle_destroy(log, &sess->handle);
(void)cleanup_result; assert(cleanup_result == XR_SUCCESS);
(void)cleanup_result;
}
return ret; return ret;
} }