From e2be2d271b9fe79e456628f58ef5d828a27edb0d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 1 Mar 2023 10:12:03 +0000 Subject: [PATCH] color-device: Make sure lcms_context is not NULL lcms interprets a NULL context as using a default, non-thread-safe context, which is unsuitable for mutter's use. Make sure we're always using a non-trivial context. Helps: https://gitlab.gnome.org/GNOME/mutter/-/issues/2659 Signed-off-by: Simon McVittie Part-of: --- src/backends/meta-color-device.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-color-device.c b/src/backends/meta-color-device.c index c0a98a46f..5533a8ece 100644 --- a/src/backends/meta-color-device.c +++ b/src/backends/meta-color-device.c @@ -846,6 +846,14 @@ create_icc_profile_from_edid (MetaColorDevice *color_device, return NULL; } + lcms_context = meta_color_manager_get_lcms_context (color_manager); + if (!lcms_context) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Internal error: no LCMS context available"); + return NULL; + } + cd_icc = cd_icc_new (); chroma.Red.x = edid_info->red_x; @@ -863,7 +871,6 @@ create_icc_profile_from_edid (MetaColorDevice *color_device, transfer_curve[1] = transfer_curve[0]; transfer_curve[2] = transfer_curve[0]; - lcms_context = meta_color_manager_get_lcms_context (color_manager); lcms_profile = cmsCreateRGBProfileTHR (lcms_context, &white_point, &chroma,