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.
This commit is contained in:
Alx Sa 2024-07-15 12:30:56 +00:00
parent 4ad5760aa9
commit d8b984a4eb
2 changed files with 10 additions and 4 deletions

View File

@ -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,

View File

@ -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
);