From d8b984a4eba73ee3752dc4cf4e9571b521dd5be4 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Mon, 15 Jul 2024 12:30:56 +0000 Subject: [PATCH] pdb: Add check for indexed image to gimp_image_get_colormap () The description promises that we return NULL if the image is not in indexed mode, but we didn't actually verify that it was before continuing with the colormap code. This patch adds that verification step. --- app/pdb/image-cmds.c | 7 +++++-- pdb/groups/image.pdb | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c index 56753a768e..2ade1a5773 100644 --- a/app/pdb/image-cmds.c +++ b/app/pdb/image-cmds.c @@ -1491,8 +1491,11 @@ image_get_colormap_invoker (GimpProcedure *procedure, guchar *colormap_data; gint n_colors; - colormap_data = _gimp_image_get_colormap (image, &n_colors); - colormap = g_bytes_new_take (colormap_data, 3 * n_colors); + if (gimp_image_get_base_type (image) == GIMP_INDEXED) + { + colormap_data = _gimp_image_get_colormap (image, &n_colors); + colormap = g_bytes_new_take (colormap_data, 3 * n_colors); + } } return_vals = gimp_procedure_get_return_values (procedure, success, diff --git a/pdb/groups/image.pdb b/pdb/groups/image.pdb index ef3a859288..11db7ce8ee 100644 --- a/pdb/groups/image.pdb +++ b/pdb/groups/image.pdb @@ -1473,8 +1473,11 @@ HELP guchar *colormap_data; gint n_colors; - colormap_data = _gimp_image_get_colormap (image, &n_colors); - colormap = g_bytes_new_take (colormap_data, 3 * n_colors); + if (gimp_image_get_base_type (image) == GIMP_INDEXED) + { + colormap_data = _gimp_image_get_colormap (image, &n_colors); + colormap = g_bytes_new_take (colormap_data, 3 * n_colors); + } } CODE );