summaryrefslogtreecommitdiff
path: root/gtk/gtkimcontextwayland.c
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2018-07-28 10:37:21 -0700
committerChristian Hergert <chergert@redhat.com>2018-07-28 10:54:14 -0700
commit002e48c469be2a4506153f692124631d3f3cf13a (patch)
tree63f3db2f02c2812b7f708fe6a9436618a4085520 /gtk/gtkimcontextwayland.c
parentf33549da9126e99cca234c437f045b19575fc37a (diff)
downloadgtk+-002e48c469be2a4506153f692124631d3f3cf13a.tar.gz
imwayland: fix potential leak of attr list
This fixes a potential leak of a PangoAttrList that is set when chaining up to the parent get_preedit_string(). We check to see if the attr list was created and reuse it instead of leaking the previous value.
Diffstat (limited to 'gtk/gtkimcontextwayland.c')
-rw-r--r--gtk/gtkimcontextwayland.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 141ad6c6c9..07d9628915 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -469,6 +469,9 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
const char *preedit_str;
+ if (attrs)
+ *attrs = NULL;
+
GTK_IM_CONTEXT_CLASS (gtk_im_context_wayland_parent_class)->get_preedit_string (context, str, attrs, cursor_pos);
/* If the parent implementation returns a len>0 string, go with it */
@@ -490,7 +493,8 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
if (attrs)
{
- *attrs = pango_attr_list_new ();
+ if (!*attrs)
+ *attrs = pango_attr_list_new ();
pango_attr_list_insert (*attrs,
pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
}