Fix memory leaks in error handlings

- Resolves #2297147 Add directory datadir/GConf/gsettings
- Resolves #2297735 Move ibus.conf to ibus-xinit sub package
This commit is contained in:
Takao Fujiwara 2024-07-18 18:34:08 +09:00
parent 15f9f3c991
commit f553865bc8
2 changed files with 92 additions and 29 deletions

View File

@ -0,0 +1,68 @@
From a1a2fe5d13ad76956a94c0695af15d76e3edfdca Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 18 Jul 2024 01:25:41 +0900
Subject: [PATCH] Fix memory leaks in error handlings
- bus/ibusimpl: Free keys not in case of TYPE_IME_SWITCHER
- src/ibuscomposetable: Correct handling G_MAXSIZE * G_MAXSIZE
- src/ibuscomposetable: Fee ibus_compose_seqs in error handlings
---
bus/ibusimpl.c | 3 ++-
src/ibuscomposetable.c | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c
index 31a095f3..445c062b 100644
--- a/bus/ibusimpl.c
+++ b/bus/ibusimpl.c
@@ -1986,7 +1986,8 @@ _ibus_set_global_shortcut_keys (BusIBusImpl *ibus,
}
ibus->ime_switcher_keys = keys;
break;
- default:;
+ default:
+ g_slice_free1 (sizeof (IBusProcessKeyEventData) * (size + 1), keys);
}
return TRUE;
}
diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c
index 7531a4b2..a8e41a33 100644
--- a/src/ibuscomposetable.c
+++ b/src/ibuscomposetable.c
@@ -849,7 +849,7 @@ compose_data_to_variant (gconstpointer compose_data,
g_assert (compose_data);
if (error)
*error = NULL;
- if ((index_stride * n_seqs) > G_MAXUINT64) {
+ if (n_seqs == 0 || index_stride > (G_MAXSIZE / n_seqs)) {
if (error) {
g_set_error (error, IBUS_ERROR, IBUS_ERROR_FAILED,
"Length %u x %lu is too long",
@@ -1404,6 +1404,7 @@ ibus_compose_table_new_with_list (GList *compose_list,
(G_MAXSIZE / sizeof (guint16)))) {
g_warning ("Too long allocation %lu x %u",
s_size_total - s_size_16bit, n_index_stride);
+ g_free (ibus_compose_seqs);
return NULL;
}
rawdata = (gpointer)g_new (
@@ -1416,6 +1417,8 @@ ibus_compose_table_new_with_list (GList *compose_list,
s_size_total - s_size_16bit,
n_index_stride,
v_size_32bit);
+ g_free (ibus_compose_seqs);
+ g_free (rawdata);
return NULL;
}
if (G_LIKELY (rawdata)) {
@@ -1432,6 +1435,7 @@ ibus_compose_table_new_with_list (GList *compose_list,
}
if (!ibus_compose_seqs_32bit_first || !ibus_compose_seqs_32bit_second) {
g_warning ("Failed g_new");
+ g_free (ibus_compose_seqs);
g_free (rawdata);
return NULL;
}
--
2.45.0

View File

@ -30,6 +30,7 @@
%bcond_with gtk4
%endif
%global ibus_xinit_condition %ibus_panel_condition
# FIXME: How to write a condition with multiple lines
%global ibus_panel_condition (%pcd1 or %pcd2 or %pcd3)
%global pcd1 budgie-desktop or cinnamon or deepin-desktop or i3
@ -61,7 +62,7 @@
Name: ibus
Version: 1.5.31~beta1
# https://github.com/fedora-infra/rpmautospec/issues/101
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPL-2.1-or-later
URL: https://github.com/ibus/%name/wiki
@ -72,7 +73,7 @@ Source3: %{name}.conf.5
# Patch0: %%{name}-HEAD.patch
# Under testing #1349148 #1385349 #1350291 #1406699 #1432252 #1601577
Patch1: %{name}-1385349-segv-bus-proxy.patch
%if %{without xinit}
%if 0%{?rhel} > 8
# Use mutter window manager in RHEL CI
Patch100: %{name}-xx-desktop-testing-mutter.patch
%endif
@ -122,7 +123,8 @@ Requires: (%{name}-gtk2%{?_isa} = %{version}-%{release} if gtk2)
%endif
Requires: %{name}-gtk3%{?_isa} = %{version}-%{release}
Requires: %{name}-setup = %{version}-%{release}
Requires: (%{name}-panel%{?_isa} = %{version}-%{release} if %ibus_panel_condition)
Requires: (%{name}-panel%{?_isa} = %{version}-%{release} if %ibus_panel_condition)
Requires: (%{name}-xinit = %{version}-%{release} if %ibus_xinit_condition)
Requires: iso-codes
Requires: dconf
@ -132,15 +134,6 @@ Requires: dconf
Requires: python3-gobject
# https://bugzilla.redhat.com/show_bug.cgi?id=1161871
%{?__python3:Requires: %{__python3}}
%if %{with xinit}
# Owner of %%{_sysconfdir}/X11/xinit
Requires: xorg-x11-xinit
Requires: setxkbmap
%endif
%if (0%{?fedora} > 29 || 0%{?rhel} > 8)
%else
Requires: dbus-x11
%endif
Requires: desktop-file-utils
Requires(post): desktop-file-utils
@ -263,8 +256,9 @@ This package contains IBus IM module for Wayland
Summary: IBus Panel icon
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
%if %{without xinit}
# ibus-xinit is not available in RHEL
%if %{with xinit}
# setxkbmap can change XKB options for Xorg desktop sessions
Requires: setxkbmap
%endif
BuildRequires: libdbusmenu-gtk3-devel
@ -274,16 +268,18 @@ in non-GNOME desktop sessions likes XFCE or Plasma because gnome-shell
shows the IBus Icon. This package depends on libdbusmenu-gtk3 for Wayland
desktop sessions.
%if %{without xinit}
%package xinit
Summary: IBus Xinit
Requires: %{name} = %{version}-%{release}
%if %{with xinit}
# Owner of %%{_sysconfdir}/X11/xinit
Requires: xorg-x11-xinit
%endif
BuildArch: noarch
%description xinit
This package includes xinit scripts to set environment variables of IBus
for Xorg desktop sessions and this is not needed by Wayland desktop sessions.
%endif
%package devel
Summary: Development tools for ibus
@ -493,6 +489,8 @@ dconf update || :
%{_datadir}/applications/org.freedesktop.IBus.Panel.Extension.Gtk3.desktop
%{_datadir}/bash-completion/completions/ibus.bash
%{_datadir}/dbus-1/services/*.service
%dir %{_datadir}/GConf
%dir %{_datadir}/GConf/gsettings
%{_datadir}/GConf/gsettings/*
%{_datadir}/glib-2.0/schemas/*.xml
%{_datadir}/ibus/component
@ -505,9 +503,6 @@ dconf update || :
%{_datadir}/man/man7/ibus-emoji.7.gz
%{_datadir}/man/man5/00-upstream-settings.5.gz
%{_datadir}/man/man5/ibus.5.gz
%if %{with xinit}
%{_datadir}/man/man5/ibus.conf.5.gz
%endif
%{_libexecdir}/ibus-engine-simple
%{_libexecdir}/ibus-dconf
%{_libexecdir}/ibus-portal
@ -523,13 +518,6 @@ dconf update || :
%{_prefix}/lib/systemd/user/org.freedesktop.IBus.session.*.service
%python3_sitearch/gi/overrides/__pycache__/*.py*
%python3_sitearch/gi/overrides/IBus.py
%if %{with xinit}
# ibus owns xinput.d because gnome does not like to depend on imsettings.
%dir %{_sysconfdir}/X11/xinit/xinput.d
# Do not use %%config(noreplace) to always get the new keywords in _xinputconf
# For user customization, $HOME/.xinputrc can be used instead.
%config %{_xinputconf}
%endif
%verify(not mtime) %dir %pkgcache
%verify(not mtime) %dir %pkgcache/bus
# 'ibus write-cache --system' updates the system cache.
@ -584,14 +572,16 @@ dconf update || :
%{_datadir}/applications/org.freedesktop.IBus.Panel.Wayland.Gtk3.desktop
%{_libexecdir}/ibus-ui-gtk3
%if %{without xinit}
%files xinit
%{_datadir}/man/man5/ibus.conf.5.gz
%if %{without xinit}
# ibus owns xinit directory without xorg-x11-xinit package
%dir %{_sysconfdir}/X11/xinit
%dir %{_sysconfdir}/X11/xinit/xinput.d
%config %{_xinputconf}
%endif
# Do not use %%config(noreplace) to always get the new keywords in _xinputconf
# For user customization, $HOME/.xinputrc can be used instead.
%config %{_xinputconf}
%files devel
%{_libdir}/ibus
@ -624,7 +614,12 @@ dconf update || :
%{_datadir}/installed-tests/ibus
%changelog
* Fri Jul 12 2024 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.31~beta1-1
* Thu Jul 18 2024 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.31~beta1-7
- Resolves #2297147 Add directory datadir/GConf/gsettings
- Resolves #2297735 Move ibus.conf to ibus-xinit sub package
- Fix memory leaks in error handlings
* Fri Jul 12 2024 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.31~beta1-6
- Bump to 1.5.31-beta1
* Mon Jun 10 2024 Python Maint <python-maint@redhat.com> - 1.5.30-6