From d2007d7dc1ffb38a24922a7842c7cebbdbab46ee Mon Sep 17 00:00:00 2001 From: Yixue Wang Date: Fri, 18 Jul 2025 17:56:22 +0800 Subject: [PATCH] types/color_representation: correctly cleanup in manager create Global should be created after all other initialization finished. Free manager in err_options. --- types/wlr_color_representation_v1.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/wlr_color_representation_v1.c b/types/wlr_color_representation_v1.c index 0bf33d156..dbf2ecd52 100644 --- a/types/wlr_color_representation_v1.c +++ b/types/wlr_color_representation_v1.c @@ -366,14 +366,6 @@ struct wlr_color_representation_manager_v1 *wlr_color_representation_manager_v1_ return NULL; } - manager->global = wl_global_create(display, - &wp_color_representation_manager_v1_interface, - version, manager, manager_bind); - if (manager->global == NULL) { - free(manager); - return NULL; - } - bool ok = true; ok &= memdup(&manager->supported_alpha_modes, options->supported_alpha_modes, @@ -385,6 +377,13 @@ struct wlr_color_representation_manager_v1 *wlr_color_representation_manager_v1_ goto err_options; } + manager->global = wl_global_create(display, + &wp_color_representation_manager_v1_interface, + version, manager, manager_bind); + if (manager->global == NULL) { + goto err_options; + } + manager->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &manager->display_destroy); @@ -393,6 +392,7 @@ struct wlr_color_representation_manager_v1 *wlr_color_representation_manager_v1_ err_options: free(manager->supported_alpha_modes); free(manager->supported_coeffs_and_ranges); + free(manager); return NULL; }