From 508e0648b5564c315379f61a8cf4c1771928850a Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 27 Jul 2018 23:46:31 -0700 Subject: [PATCH] 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. --- modules/input/imwayland.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/input/imwayland.c b/modules/input/imwayland.c index 7e781cb987..96ffbae82c 100644 --- a/modules/input/imwayland.c +++ b/modules/input/imwayland.c @@ -488,6 +488,9 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context, GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context); gchar *preedit_str; + if (attrs) + *attrs = NULL; + 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 */ @@ -509,7 +512,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)); }