From d0ec8716d7d4d0cfb0067290cac51b59b7fd4e42 Mon Sep 17 00:00:00 2001 From: NRK Date: Thu, 18 May 2023 15:06:44 +0000 Subject: fix: calling imlib2 with color modifier being NULL (#440) the multiframe loaders sets the color modifier to NULL but doesn't restore it before returning. this results in a imlib2 developer warning if you try to change brightness/contrast on a multiframe image (which doesn't have alpha). ensure that the color modifier is restored before returning under all paths. Reported-by: Madhu Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/440 Reviewed-by: eylles --- image.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/image.c b/image.c index 49dc72f..4f9015d 100644 --- a/image.c +++ b/image.c @@ -470,11 +470,6 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) m->frames = erealloc(m->frames, m->cap * sizeof(*m->frames)); } - imlib_context_set_dither(0); - imlib_context_set_anti_alias(0); - imlib_context_set_color_modifier(NULL); - imlib_context_set_operation(IMLIB_OP_COPY); - if ((blank = imlib_create_image(img->w, img->h)) == NULL) { error(0, 0, "%s: couldn't create image", file->name); return false; @@ -482,6 +477,11 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) imlib_context_set_image(blank); img_area_clear(0, 0, img->w, img->h); + imlib_context_set_dither(0); + imlib_context_set_anti_alias(0); + imlib_context_set_color_modifier(NULL); + imlib_context_set_operation(IMLIB_OP_COPY); + /* * Imlib2 gives back a "raw frame", we need to blend it on top of the * previous frame ourselves if necessary to get the fully decoded frame. @@ -548,6 +548,7 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) imlib_context_set_image(blank); imlib_free_image(); img_multiframe_context_set(img); + imlib_context_set_color_modifier(img->cmod); /* restore cmod */ return m->cnt > 0; } #endif /* HAVE_IMLIB2_MULTI_FRAME */ -- cgit v1.2.3-54-g00ecf