Fix a couple of memory leaks

Resolves: #1641254
This commit is contained in:
Jonas Ådahl 2018-10-20 16:22:49 +02:00 committed by Kalev Lember
parent 75565b2364
commit bd4d6ff3e4
3 changed files with 139 additions and 1 deletions

View File

@ -0,0 +1,94 @@
From 71a62bb18fe3aebc6668bd37ef6917398ef71ae1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Sat, 20 Oct 2018 15:46:37 +0200
Subject: [PATCH 1/2] constraints: Make current placement rule stack allocated
We're not going to keep it past the function scope, so no reason to put
it on the heap. We also didn't free it, so this'll fix a memory leak.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/653
---
src/core/constraints.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/core/constraints.c b/src/core/constraints.c
index a205ea0fd7..3652b3d8e1 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -787,7 +787,7 @@ constrain_custom_rule (MetaWindow *window,
MetaPlacementRule *placement_rule;
MetaRectangle intersection;
gboolean constraint_satisfied;
- MetaPlacementRule *current_rule;
+ MetaPlacementRule current_rule;
MetaWindow *parent;
MetaRectangle parent_rect;
@@ -820,25 +820,24 @@ constrain_custom_rule (MetaWindow *window,
if (check_only)
return constraint_satisfied;
- current_rule = g_new0 (MetaPlacementRule, 1);
- *current_rule = *placement_rule;
+ current_rule = *placement_rule;
if (constraint_satisfied)
goto done;
if (info->current.width != intersection.width &&
- (current_rule->constraint_adjustment &
+ (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_X))
{
- try_flip_window_position (window, info, current_rule,
+ try_flip_window_position (window, info, &current_rule,
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_X,
&info->current, &intersection);
}
if (info->current.height != intersection.height &&
- (current_rule->constraint_adjustment &
+ (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_Y))
{
- try_flip_window_position (window, info, current_rule,
+ try_flip_window_position (window, info, &current_rule,
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_Y,
&info->current, &intersection);
}
@@ -852,7 +851,7 @@ constrain_custom_rule (MetaWindow *window,
if (constraint_satisfied)
goto done;
- if (current_rule->constraint_adjustment &
+ if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_SLIDE_X)
{
if (info->current.x != intersection.x)
@@ -860,7 +859,7 @@ constrain_custom_rule (MetaWindow *window,
else if (info->current.width != intersection.width)
info->current.x -= info->current.width - intersection.width;
}
- if (current_rule->constraint_adjustment &
+ if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_SLIDE_Y)
{
if (info->current.y != intersection.y)
@@ -878,13 +877,13 @@ constrain_custom_rule (MetaWindow *window,
if (constraint_satisfied)
goto done;
- if (current_rule->constraint_adjustment &
+ if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_RESIZE_X)
{
info->current.x = intersection.x;
info->current.width = intersection.width;
}
- if (current_rule->constraint_adjustment &
+ if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_RESIZE_Y)
{
info->current.y = intersection.y;
--
2.19.1

View File

@ -0,0 +1,37 @@
From 8200995fdbf04b2763d33cd30d7c8174eebc1736 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Sat, 20 Oct 2018 15:47:50 +0200
Subject: [PATCH 2/2] shaped-texture: Clean up texture regions
We allocated texture regions, but didn't free them when finished,
causing a leak.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/653
---
src/compositor/meta-shaped-texture.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 5328a919ea..cd151a28ed 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -516,6 +516,7 @@ meta_shaped_texture_paint (ClutterActor *actor)
}
else
{
+ opaque_tex_region = NULL;
use_opaque_region = FALSE;
}
@@ -659,6 +660,8 @@ meta_shaped_texture_paint (ClutterActor *actor)
}
}
+ g_clear_pointer (&clip_tex_region, cairo_region_destroy);
+ g_clear_pointer (&opaque_tex_region, cairo_region_destroy);
g_clear_pointer (&blended_tex_region, cairo_region_destroy);
}
--
2.19.1

View File

@ -7,7 +7,7 @@
Name: mutter
Version: 3.30.1
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Window and compositing manager based on Clutter
License: GPLv2+
@ -20,6 +20,10 @@ Patch0: startup-notification.patch
# Fix disabled monitor when laptop lid is closed (rhbz#1638444)
Patch1: 0001-monitor-manager-Don-t-use-switch-config-when-ensurin.patch
# Backport memory leak fixes (rhbz#1641254)
Patch2: 0001-constraints-Make-current-placement-rule-stack-alloca.patch
Patch3: 0002-shaped-texture-Clean-up-texture-regions.patch
BuildRequires: chrpath
BuildRequires: pango-devel
BuildRequires: startup-notification-devel
@ -184,6 +188,9 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop
%{_datadir}/mutter/tests
%changelog
* Sat Oct 20 2018 Jonas Ådahl <jadahl@redhat.com> - 3.30.1-4
- Backport a couple of memory leak fixes (rhbz#1641254)
* Thu Oct 11 2018 Jonas Ådahl <jadahl@redhat.com> - 3.30.1-3
- Fix disabled monitor when laptop lid is closed (rhbz#1638444)