public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/ibus] rawhide: Fix IBusAttrList leak when converting text
@ 2026-08-30 15:27 Takao Fujiwara
  0 siblings, 0 replies; only message in thread
From: Takao Fujiwara @ 2026-08-30 15:27 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/ibus
            Branch : rawhide
            Commit : 32c8d67c8f1f30c17f352f805cad7166f3e7459d
            Author : Takao Fujiwara <tfujiwar@redhat.com>
            Date   : 2026-08-31T00:24:35+09:00
            Stats  : +123/-2 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/ibus/c/32c8d67c8f1f30c17f352f805cad7166f3e7459d?branch=rawhide

            Log:
            Fix IBusAttrList leak when converting text

Also update CI timeout to 30min.

---
diff --git a/ibus-HEAD.patch b/ibus-HEAD.patch
index e69de29..6054b2f 100644
--- a/ibus-HEAD.patch
+++ b/ibus-HEAD.patch
@@ -0,0 +1,117 @@
+From 1a331e695d84fc6bae8f2d11c52d4776df49647b Mon Sep 17 00:00:00 2001
+From: Sebastian Keller <skeller@gnome.org>
+Date: Thu, 27 Aug 2026 21:07:58 +0200
+Subject: [PATCH] src: Fix IBusAttrList leak when converting text
+
+After 5bbe88a1 the attribute list set on the text was getting leaked
+when the list passed to `ibus_attr_list_copy_format_to_*()` had a length
+of 0. In that case the list is already non-floating before the copy
+function adds a ref and returns it. This then is passed to
+`ibus_text_set_attributes()` which calls `g_object_ref_sink()`. Since
+the list is not floating, this adds another ref that would not be added
+in the length > 0 case. This surplus ref is causing the list to be
+leaked.
+
+To fix this leak we need to unref the list after calling
+`ibus_text_set_attributes()`.
+
+However in the length > 0 case the new list returned by
+`ibus_attr_list_copy_format_to_*()` is floating, so this would drop the
+refcount to 0. To avoid this we need to ensure that if the list is floating the
+floating ref is sunk before calling `ibus_text_set_attributes()`, so the
+call to `g_object_ref_sink()` in there adds a ref, such that we can
+safely unref this after the call to `ibus_text_set_attributes()`.
+
+This also keeps the guarantee that the list is not floating anymore
+after converting text to not regress the issue fixed by 5bbe88a1.
+
+Fixes: https://github.com/ibus/ibus/commit/5bbe88a1
+Closes: https://github.com/ibus/ibus/issues/2941
+---
+ src/ibusinputcontext.c | 20 ++++++++++++++++++--
+ src/ibuspanelservice.c | 20 ++++++++++++++++++--
+ 2 files changed, 36 insertions(+), 4 deletions(-)
+
+diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c
+index bdfd166d..d0e162fc 100644
+--- a/src/ibusinputcontext.c
++++ b/src/ibusinputcontext.c
+@@ -569,8 +569,16 @@ ibus_input_context_convert_text (IBusInputContext *context,
+                        text->text, error->message);
+             g_error_free (error);
+         }
+-        if (new_attrs)
++        if (new_attrs) {
++#if GLIB_CHECK_VERSION (2, 70, 0)
++            g_object_take_ref (new_attrs);
++#else
++            if (g_object_is_floating (new_attrs)
++                g_object_ref_sink (new_attrs);
++#endif
+             ibus_text_set_attributes (text, new_attrs);
++            g_object_unref (new_attrs);
++        }
+         break;
+     case IBUS_PREEDIT_FORMAT_HINT:
+         new_attrs = ibus_attr_list_copy_format_to_hint (text->attrs, &error);
+@@ -579,8 +587,16 @@ ibus_input_context_convert_text (IBusInputContext *context,
+                        text->text, error->message);
+             g_error_free (error);
+         }
+-        if (new_attrs)
++        if (new_attrs) {
++#if GLIB_CHECK_VERSION (2, 70, 0)
++            g_object_take_ref (new_attrs);
++#else
++            if (g_object_is_floating (new_attrs)
++                g_object_ref_sink (new_attrs);
++#endif
+             ibus_text_set_attributes (text, new_attrs);
++            g_object_unref (new_attrs);
++        }
+         break;
+     default:
+         g_assert_not_reached ();
+diff --git a/src/ibuspanelservice.c b/src/ibuspanelservice.c
+index 14cca3ec..18404a39 100644
+--- a/src/ibuspanelservice.c
++++ b/src/ibuspanelservice.c
+@@ -1203,8 +1203,16 @@ ibus_panel_convert_text (IBusPanelService *panel,
+                        text->text, error->message);
+             g_error_free (error);
+         }
+-        if (new_attrs)
++        if (new_attrs) {
++#if GLIB_CHECK_VERSION (2, 70, 0)
++            g_object_take_ref (new_attrs);
++#else
++            if (g_object_is_floating (new_attrs)
++                g_object_ref_sink (new_attrs);
++#endif
+             ibus_text_set_attributes (text, new_attrs);
++            g_object_unref (new_attrs);
++        }
+         break;
+     case IBUS_PREEDIT_FORMAT_HINT:
+         new_attrs = ibus_attr_list_copy_format_to_hint (text->attrs, &error);
+@@ -1213,8 +1221,16 @@ ibus_panel_convert_text (IBusPanelService *panel,
+                        text->text, error->message);
+             g_error_free (error);
+         }
+-        if (new_attrs)
++        if (new_attrs) {
++#if GLIB_CHECK_VERSION (2, 70, 0)
++            g_object_take_ref (new_attrs);
++#else
++            if (g_object_is_floating (new_attrs)
++                g_object_ref_sink (new_attrs);
++#endif
+             ibus_text_set_attributes (text, new_attrs);
++            g_object_unref (new_attrs);
++        }
+         break;
+     default:
+         g_assert_not_reached ();
+-- 
+2.55.0
+

diff --git a/ibus.spec b/ibus.spec
index 7985f97..78f5f73 100644
--- a/ibus.spec
+++ b/ibus.spec
@@ -48,7 +48,7 @@
 Name:           ibus
 Version:        1.5.35~beta2
 # https://github.com/fedora-infra/rpmautospec/issues/101
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Intelligent Input Bus for Linux OS
 License:        LGPL-2.1-or-later
 URL:            https://github.com/ibus/%name/wiki
@@ -57,6 +57,7 @@ Source1:        https://github.com/ibus/%name/releases/download/%{source_version
 Source2:        %{name}-xinput
 Source3:        %{name}.conf.5
 # Patch:          %%{name}-HEAD.patch
+Patch:          %{name}-HEAD.patch
 # Under testing #1349148 #1385349 #1350291 #1406699 #1432252 #1601577
 Patch:          %{name}-1385349-segv-bus-proxy.patch
 
@@ -548,6 +549,9 @@ dconf update || :
 %{_datadir}/installed-tests/ibus
 
 %changelog
+* Sun Aug 30 2026 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.35~beta2-2
+- Fix IBusAttrList leak when converting text
+
 * Wed Aug 26 2026 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.35~beta2-1
 - Fix match rules in ibus-daemon
 - Update meson builds

diff --git a/tests/ibus-desktop-testing/run/main.fmf b/tests/ibus-desktop-testing/run/main.fmf
index d2434b1..10358f5 100644
--- a/tests/ibus-desktop-testing/run/main.fmf
+++ b/tests/ibus-desktop-testing/run/main.fmf
@@ -1,5 +1,5 @@
 summary: Run tests
 description:
     Run CI with ibus-desktop-testing-runner in GNOME Wayland.
-duration: 15m
+duration: 30m
 test: ./test.sh

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-30 15:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-30 15:27 [rpms/ibus] rawhide: Fix IBusAttrList leak when converting text Takao Fujiwara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox