mirror of https://github.com/GNOME/gimp.git
plug-ins: Fix GIH export crash due to selection-modes
Like ranks, the number of selection modes are defined by gihparams.dim. However, we were unconditionally setting GimpProcedureConfig's "selection-modes" parameter to the gihparams.selection array, which might have more elements than we had dimensions. This caused a crash. This patch moves the selection-modes code into the check for gihparams.dim > 0, and copies only the relevant values into a separate array to set them.
This commit is contained in:
parent
3286dbb4f4
commit
c57bf3c6bd
|
@ -326,25 +326,35 @@ gih_export (GimpProcedure *procedure,
|
|||
parasite_data = g_strndup (parasite_data, parasite_size);
|
||||
|
||||
gimp_pixpipe_params_parse (parasite_data, &gihparams);
|
||||
|
||||
g_object_set (config,
|
||||
"num-cells", gihparams.ncells,
|
||||
"dimension", gihparams.dim,
|
||||
"selection-modes", gihparams.selection,
|
||||
NULL);
|
||||
|
||||
if (gihparams.dim > 0)
|
||||
{
|
||||
GBytes *ranks = NULL;
|
||||
guint8 rank_int[gihparams.dim];
|
||||
gchar **selection_modes;
|
||||
|
||||
selection_modes = g_new0 (gchar *, gihparams.dim + 1);
|
||||
|
||||
for (gint i = 0; i < gihparams.dim; i++)
|
||||
{
|
||||
selection_modes[i] = gihparams.selection[i];
|
||||
rank_int[i] = (guint8) gihparams.rank[i];
|
||||
}
|
||||
|
||||
ranks =
|
||||
g_bytes_new (rank_int, sizeof (guint8) * gihparams.dim);
|
||||
g_object_set (config, "ranks", ranks, NULL);
|
||||
g_object_set (config,
|
||||
"ranks", ranks,
|
||||
"selection-modes", selection_modes,
|
||||
NULL);
|
||||
|
||||
g_bytes_unref (ranks);
|
||||
g_free (selection_modes);
|
||||
}
|
||||
|
||||
gimp_parasite_free (parasite);
|
||||
|
|
Loading…
Reference in New Issue