d/psvr: Fix use after free of timekeeping

This commit is contained in:
Jakob Bornecrantz 2019-11-15 15:23:25 +00:00
parent b33811930b
commit 76445c8fe9

View file

@ -875,8 +875,6 @@ teardown(struct psvr_device *psvr)
// Stop the variable tracking.
u_var_remove_root(psvr);
time_state_destroy(psvr->timekeeping);
// Includes null check, and sets to null.
xrt_tracked_psvr_destroy(&psvr->tracker);
@ -895,6 +893,15 @@ teardown(struct psvr_device *psvr)
hid_close(psvr->hmd_handle);
psvr->hmd_handle = NULL;
}
/*
* This needs to happen last because when waiting for
* device control changes we can get IMU update packets.
*/
if (psvr->timekeeping != NULL) {
time_state_destroy(psvr->timekeeping);
psvr->timekeeping = NULL;
}
}