plug-ins: Fix crash when editing Gradient Flare

As Lloyd Konneker noted, the calc.sflare_list was not being
accessed at the right location when the Edit Dialog preview of
the gradient was updated. The API page for g_list_free_full ()
recommends using g_steal_pointer () to ensure the head element
is not left dangling. This aligns with other usage in the GIMP codebase
and seems to stop the crash. Additional safety checks were
also added.
This commit is contained in:
Alx Sa 2024-08-08 04:27:46 +00:00
parent c95fe605cd
commit ddfb4d4f73
1 changed files with 11 additions and 3 deletions

View File

@ -2109,7 +2109,8 @@ calc_deinit (void)
return;
}
g_list_free_full (calc.sflare_list, (GDestroyNotify) g_free);
g_list_free_full (g_steal_pointer (&calc.sflare_list), (GDestroyNotify) g_free);
calc.sflare_list = NULL;
g_free (calc.glow_radial);
g_free (calc.glow_angular);
@ -2276,7 +2277,10 @@ calc_rays_pix (guchar *dest_pix, gdouble x, gdouble y)
* glow, rays $B$O4J0W2=$N$?$a$K$J$7!#(B
*/
void
calc_sflare_pix (guchar *dest_pix, gdouble x, gdouble y, guchar *src_pix)
calc_sflare_pix (guchar *dest_pix,
gdouble x,
gdouble y,
guchar *src_pix)
{
GList *list;
CalcSFlare *sflare;
@ -2290,11 +2294,15 @@ calc_sflare_pix (guchar *dest_pix, gdouble x, gdouble y, guchar *src_pix)
return;
list = calc.sflare_list;
while (list)
{
sflare = list->data;
list = list->next;
if (! sflare)
break;
if (x < sflare->bounds.x0 || x > sflare->bounds.x1
|| y < sflare->bounds.y0 || y > sflare->bounds.y1)
continue;
@ -2862,7 +2870,7 @@ dlg_preview_deinit_func (Preview *preview, gpointer data)
if (dlg->init_params_done)
{
calc_deinit ();
dlg->init_params_done = TRUE;
dlg->init_params_done = FALSE;
}
}