Repository navigation
src: Fix IBusAttrList leak when converting text - #2943
Merged
Merged
Conversation
fujiwarat
reviewed
Aug 30, 2026
After 5bbe88a 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 5bbe88a. Fixes: ibus@5bbe88a1 Closes: ibus#2941
sbstnk
force-pushed
the
fix-attr-list-leak
branch
from
August 30, 2026 11:05
9b77728 to
1a331e6
Compare
malfisya
added a commit
to getsolus/packages
that referenced
this pull request
Oct 18, 2026
**Summary** Patches taken from: - ibus/ibus#2929 - ibus/ibus#2890 - ibus/ibus#2943 Upstream issues: - https://gitlab.gnome.org/GNOME/gnome-shell/-/work_items/9401 - https://gitlab.gnome.org/GNOME/gtk/-/work_items/8341
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After 5bbe88a 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 toibus_text_set_attributes()which callsg_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 callingibus_text_set_attributes(), so the call tog_object_ref_sink()in there adds a ref, such that we can safely unref this after the call toibus_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 5bbe88a.
Fixes: 5bbe88a1
Closes: #2941