plug-ins: Fix crash when loading CMYK JPEG 2000 images

When converting a CMYK JPEG 2000 image to RGB, we freed
the Key array. Since it is still in use, this caused the
plug-in to crash. This patch replaces this with lowering
the component content and letting the OpenJPEG clean up
process handle this work instead.
This commit is contained in:
Alx Sa 2025-02-19 08:06:10 -05:00
parent 535d0183be
commit 127cd67118
1 changed files with 6 additions and 2 deletions

View File

@ -797,8 +797,6 @@ color_cmyk_to_rgb (opj_image_t *image)
image->comps[2].data[i] = (int) (255.0f * Y * K); /* B */
}
free (image->comps[3].data);
image->comps[3].data = NULL;
image->comps[0].prec = 8;
image->comps[1].prec = 8;
image->comps[2].prec = 8;
@ -811,6 +809,10 @@ color_cmyk_to_rgb (opj_image_t *image)
sizeof (image->comps[i]));
}
/* Restore the count so the OpenJPEG destroy function works
* properly */
image->numcomps += 1;
return TRUE;
}
@ -1212,6 +1214,8 @@ load_image (GimpProcedure *procedure,
gimp_file_get_utf8_name (file));
goto out;
}
num_components--;
}
else if (image->color_space == OPJ_CLRSPC_EYCC)
{