From 85ffdd57f4d4ad6b174d2085aea22452dc72b160 Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Wed, 9 Jun 2021 18:29:41 -0400 Subject: [PATCH] win-capture: Return early in property callbacks if param is null When obs_get_source_properties is called, it calls the property modified callbacks without a source instantiation. The callbacks set in .get_properties for display capture and window capture would then result in exceptions when anything is dereferenced on the source, such as wgc_supported or update_mutex, because the source itself is null. Let's make the callbacks return early if the property param is null. --- plugins/win-capture/duplicator-monitor-capture.c | 3 +++ plugins/win-capture/window-capture.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/plugins/win-capture/duplicator-monitor-capture.c b/plugins/win-capture/duplicator-monitor-capture.c index 59cb63342..ad02b4b4c 100644 --- a/plugins/win-capture/duplicator-monitor-capture.c +++ b/plugins/win-capture/duplicator-monitor-capture.c @@ -628,6 +628,9 @@ static bool display_capture_method_changed(obs_properties_t *props, UNUSED_PARAMETER(p); struct duplicator_capture *capture = obs_properties_get_param(props); + if (!capture) + return false; + update_settings(capture, settings); update_settings_visibility(props, capture); diff --git a/plugins/win-capture/window-capture.c b/plugins/win-capture/window-capture.c index 9ce4347f5..72171f6b7 100644 --- a/plugins/win-capture/window-capture.c +++ b/plugins/win-capture/window-capture.c @@ -363,6 +363,9 @@ static bool wc_capture_method_changed(obs_properties_t *props, UNUSED_PARAMETER(p); struct window_capture *wc = obs_properties_get_param(props); + if (!wc) + return false; + update_settings(wc, settings); update_settings_visibility(props, wc); @@ -379,6 +382,9 @@ static bool wc_window_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { struct window_capture *wc = obs_properties_get_param(props); + if (!wc) + return false; + update_settings(wc, settings); update_settings_visibility(props, wc);