Skip to content

Commit

Permalink
fix memleak for styles popup
Browse files Browse the repository at this point in the history
gtk_get_current_event() returns a copy which must be freed, but
wasn't.  It is also documented as potentially returning NULL, so add a
null check as well.
  • Loading branch information
ralfbrown committed Jan 23, 2025
1 parent a27aff7 commit b93c482
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/libs/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,10 +1166,12 @@ static void _update_style(const dt_stylemenu_data_t *menu_data)
static void _apply_style_activate_callback(GtkMenuItem *menuitem,
const dt_stylemenu_data_t *menu_data)
{
if(gtk_get_current_event()->type == GDK_KEY_PRESS)
GdkEvent *event = gtk_get_current_event();
if(event && event->type == GDK_KEY_PRESS)
{
_update_style(menu_data);
}
gdk_event_free(event);
}

static gboolean _apply_style_button_callback(GtkMenuItem *menuitem,
Expand Down
4 changes: 3 additions & 1 deletion src/libs/print_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1186,10 +1186,12 @@ static void _update_style(const dt_stylemenu_data_t *menu_data)
static void _apply_style_activate_callback(GtkMenuItem *menuitem,
const dt_stylemenu_data_t *menu_data)
{
if(gtk_get_current_event()->type == GDK_KEY_PRESS)
GdkEvent *event = gtk_get_current_event();
if(event && event->type == GDK_KEY_PRESS)
{
_update_style(menu_data);
}
gdk_event_free(event);
}

static gboolean _apply_style_button_callback(GtkMenuItem *menuitem,
Expand Down

0 comments on commit b93c482

Please sign in to comment.