core: Better handle group endings in ASE palette import

This patch adds better handling for group begin and end markers
within ASE palettes. As a result, this fixes an issue where the last
color was not imported in some ASE files without groups.
Additionally, this guarantees that colors are imported using 4 bytes
per https://gitlab.gnome.org/GNOME/gimp/-/issues/10359#note_1921462
This commit is contained in:
Alx Sa 2023-11-24 06:08:09 +00:00
parent 95d062d774
commit 62da36cd43
1 changed files with 18 additions and 4 deletions

View File

@ -1079,9 +1079,6 @@ gimp_palette_load_ase (GimpContext *context,
}
g_free (palette_name);
/* Header blocks are considered a "color" so we offset the count here */
num_cols -= 1;
for (i = 0; i < num_cols; i++)
{
gchar color_space[4];
@ -1104,6 +1101,23 @@ gimp_palette_load_ase (GimpContext *context,
}
skip_first = FALSE;
/* Skip group marker padding */
group = GINT16_FROM_BE (group);
if (group < 0)
{
gchar marker[4];
if (! g_input_stream_read_all (input, &marker, sizeof (marker),
&bytes_read, NULL, error))
{
g_printerr ("Invalid ASE group marker: %s.",
gimp_file_get_utf8_name (file));
break;
}
num_cols--;
continue;
}
color_name = gimp_palette_load_ase_block_name (input, file_size, error);
if (! color_name)
break;
@ -1144,7 +1158,7 @@ gimp_palette_load_ase (GimpContext *context,
for (gint j = 0; j < components; j++)
{
gint tmp;
gint32 tmp;
if (! g_input_stream_read_all (input, &tmp, sizeof (tmp),
&bytes_read, NULL, error))