From e6f7570137b0aab0a05f2385b9ca5232c4e225a9 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 17 Mar 2020 17:03:19 +0100 Subject: [PATCH] We should not free the camera variable if it is null. This could happen in some circumstances, so we test for that case. --- src/gphoto-preview.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gphoto-preview.c b/src/gphoto-preview.c index f0bd2ff..e9c1292 100644 --- a/src/gphoto-preview.c +++ b/src/gphoto-preview.c @@ -183,9 +183,11 @@ static void capture_terminate(void *vptr){ os_event_destroy(data->event); } - gp_camera_exit(data->camera, data->gp_context); - gp_camera_free(data->camera); - data->camera = NULL; + if(data->camera) { + gp_camera_exit(data->camera, data->gp_context); + gp_camera_free(data->camera); + data->camera = NULL; + } } static void capture_update(void *vptr, obs_data_t *settings){ @@ -383,4 +385,4 @@ struct obs_source_info capture_preview_info = { .hide = capture_hide, .get_width = capture_getwidth, .get_height = capture_getheight, -}; \ No newline at end of file +};