From 39de0bd9887ecb0df9c3565af8b09ada73ab00c1 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Fri, 27 Oct 2023 12:09:59 -0300 Subject: [PATCH] color-lcms: unref stock sRGB cprof instead of directly destroying it Directly destroying the cprof is not ideal, because it may hide issues that we have in the code. If we are destroying a cprof with ref_count bigger than 1, there's something wrong that we need to fix. Instead, assert that the stock sRGB cprof has ref_count == 1 when we are destroying the color manager. And use unref() instead of destroy(). Signed-off-by: Leandro Ribeiro --- libweston/color-lcms/color-lcms.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libweston/color-lcms/color-lcms.c b/libweston/color-lcms/color-lcms.c index 656acd4ab..ba8e404f0 100644 --- a/libweston/color-lcms/color-lcms.c +++ b/libweston/color-lcms/color-lcms.c @@ -381,8 +381,11 @@ cmlcms_destroy(struct weston_color_manager *cm_base) { struct weston_color_manager_lcms *cm = get_cmlcms(cm_base); - if (cm->sRGB_profile) - cmlcms_color_profile_destroy(cm->sRGB_profile); + if (cm->sRGB_profile) { + assert(cm->sRGB_profile->base.ref_count == 1); + unref_cprof(cm->sRGB_profile); + } + assert(wl_list_empty(&cm->color_transform_list)); assert(wl_list_empty(&cm->color_profile_list));