From 6ee235ac3b76cef8c5329ca66c8c1e452896f79a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 4 Apr 2023 14:26:14 +0100 Subject: [PATCH] d/wmr: Tidy camera destroy function --- src/xrt/drivers/wmr/wmr_camera.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/xrt/drivers/wmr/wmr_camera.c b/src/xrt/drivers/wmr/wmr_camera.c index 2dcb7f6d4..d08235953 100644 --- a/src/xrt/drivers/wmr/wmr_camera.c +++ b/src/xrt/drivers/wmr/wmr_camera.c @@ -511,7 +511,6 @@ wmr_camera_open(struct wmr_camera_open_config *config) return cam; - fail: WMR_CAM_ERROR(cam, "Failed to open camera: %s", libusb_error_name(res)); wmr_camera_free(cam); @@ -540,11 +539,16 @@ wmr_camera_free(struct wmr_camera *cam) os_thread_helper_destroy(&cam->usb_thread); for (i = 0; i < NUM_XFERS; i++) { - if (cam->xfers[i] != NULL) - libusb_free_transfer(cam->xfers[i]); + if (cam->xfers[i] == NULL) { + continue; + } + + libusb_free_transfer(cam->xfers[i]); + cam->xfers[i] = NULL; } libusb_exit(cam->ctx); + cam->ctx = NULL; } // Tidy the variable tracking. @@ -552,8 +556,6 @@ wmr_camera_free(struct wmr_camera *cam) u_sink_debug_destroy(&cam->debug_sinks[0]); u_sink_debug_destroy(&cam->debug_sinks[1]); - - free(cam); }