From e3f245394a6ce00bb8955fef49d8ec458a2c437c Mon Sep 17 00:00:00 2001 From: Leon Henrik Plickat Date: Mon, 14 Jun 2021 23:08:38 +0000 Subject: [PATCH] Fix segfault when required protocol not supported --- wlopm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wlopm.c b/wlopm.c index 994328f..2803e9e 100644 --- a/wlopm.c +++ b/wlopm.c @@ -124,6 +124,7 @@ static void registry_handle_global (void *data, struct wl_registry *registry, output->wl_output = wl_registry_bind(registry, name, &wl_output_interface, version); output->xdg_output = NULL; + output->wlr_output_power = NULL; output->name = NULL; output->global_name = name; @@ -282,8 +283,10 @@ int main(int argc, char *argv[]) struct Output *output, *tmp; wl_list_for_each_safe(output, tmp, &outputs, link) { - zwlr_output_power_v1_destroy(output->wlr_output_power); - zxdg_output_v1_destroy(output->xdg_output); + if ( output->wlr_output_power != NULL ) + zwlr_output_power_v1_destroy(output->wlr_output_power); + if ( output->xdg_output != NULL ) + zxdg_output_v1_destroy(output->xdg_output); wl_output_destroy(output->wl_output); wl_list_remove(&output->link); free(output->name);