Fix a memory leak in session state changes

Resolves: RHEL-187078

Signed-off-by: Siteshwar Vashisht <svashisht@redhat.com>
This commit is contained in:
Siteshwar Vashisht 2026-07-07 13:28:12 +02:00
parent 7092c102f2
commit 0684f4d2d2
2 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,22 @@
diff --git a/src/polkit/polkitpermission.c b/src/polkit/polkitpermission.c
index 3231bf2..984771e 100644
--- a/src/polkit/polkitpermission.c
+++ b/src/polkit/polkitpermission.c
@@ -554,7 +554,7 @@ static void on_sessions_changed (PolkitAuthority *authority,
if ((new_session_state == NULL) || ( g_strcmp0(new_session_state, permission->session_state) != 0 ))
{
last_state = permission->session_state;
- permission->session_state = new_session_state;
+ permission->session_state = g_steal_pointer (&new_session_state);
g_free(last_state);
polkit_authority_check_authorization (permission->authority,
@@ -566,6 +566,8 @@ static void on_sessions_changed (PolkitAuthority *authority,
changed_check_cb,
g_object_ref (permission));
}
+
+ g_free (new_session_state);
#else
on_authority_changed(authority, user_data); /* TODO: resolve the "too many session signals" issue for non-systemd systems later */
#endif

View File

@ -6,7 +6,7 @@
Summary: An authorization framework
Name: polkit
Version: 0.115
Release: 15%{?dist}.2
Release: 15%{?dist}.3
License: LGPLv2+
URL: http://www.freedesktop.org/wiki/Software/polkit
Source0: http://www.freedesktop.org/software/polkit/releases/%{name}-%{version}.tar.gz
@ -31,6 +31,7 @@ Patch14: polkit-0.115-CVE-2021-4115.patch
Patch15: polkit-0.115-tty-flags-restore-if-changed.patch
Patch16: polkit-0.115-session-monitor-watch-sessions-only.patch
Patch17: polkit-0.115-pkperm-watch-real-ssn-changes.patch
Patch18: polkit-0.115-state-data-memleak.patch
BuildRequires: gcc-c++
@ -197,6 +198,10 @@ exit 0
%{_libdir}/girepository-1.0/*.typelib
%changelog
* Tue Jul 07 2026 Siteshwar Vashisht <svashisht@redhat.com> - 0.115-15.3
- Fix a memory leak in session state changes
- Resolves: RHEL-187078
* Mon May 20 2024 Jan Rybar <jrybar@redhat.com> - 0.115-15.2
- PolkitPermission re-check on real session changes
- Resolves: RHEL-34029