color-lcms: clean up context in init failure

This is not strictly necessary, because if init fails, then
weston_compositor_backends_loaded() fails, main.c will
weston_compositor_destroy() -> weston_compositor_shutdown() ->
cmclcms_destroy() which will free this. But that is very hard to track
down, so let's make the code obviously more correct.

We must also avoid cmsDeleteContext(NULL), because it will then do
something to the default cms context rather than bail out.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2024-02-23 16:06:48 +02:00
parent 80c0d5e643
commit 61b3ae335a

View file

@ -437,6 +437,10 @@ cmlcms_init(struct weston_color_manager *cm_base)
return true;
out_err:
if (cm->lcms_ctx)
cmsDeleteContext(cm->lcms_ctx);
cm->lcms_ctx = NULL;
weston_log_scope_destroy(cm->transforms_scope);
cm->transforms_scope = NULL;
weston_log_scope_destroy(cm->optimizer_scope);
@ -480,7 +484,8 @@ cmlcms_destroy(struct weston_color_manager *cm_base)
assert(wl_list_empty(&cm->color_transform_list));
assert(wl_list_empty(&cm->color_profile_list));
cmsDeleteContext(cm->lcms_ctx);
if (cm->lcms_ctx)
cmsDeleteContext(cm->lcms_ctx);
weston_log_scope_destroy(cm->transforms_scope);
weston_log_scope_destroy(cm->optimizer_scope);