Merge branch 'wip/chergert/imwayland-leak' into 'gtk-3-24'

imwayland: fix potential leak of attr list

See merge request GNOME/gtk!277
This commit is contained in:
Carlos Garnacho 2018-07-28 10:14:56 +00:00
commit ffa4e2308a

View File

@ -488,6 +488,9 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context); GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
gchar *preedit_str; gchar *preedit_str;
if (attrs)
*attrs = NULL;
GTK_IM_CONTEXT_CLASS (parent_class)->get_preedit_string (context, str, attrs, cursor_pos); GTK_IM_CONTEXT_CLASS (parent_class)->get_preedit_string (context, str, attrs, cursor_pos);
/* If the parent implementation returns a len>0 string, go with it */ /* If the parent implementation returns a len>0 string, go with it */
@ -509,7 +512,8 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
if (attrs) if (attrs)
{ {
*attrs = pango_attr_list_new (); if (!*attrs)
*attrs = pango_attr_list_new ();
pango_attr_list_insert (*attrs, pango_attr_list_insert (*attrs,
pango_attr_underline_new (PANGO_UNDERLINE_SINGLE)); pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
} }