[gnome-settings-daemon/benzea/minor-fix-collection: 12/19] power: Fix potential manager reference count leak
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/minor-fix-collection: 12/19] power: Fix potential manager reference count leak
- Date: Mon, 15 Apr 2019 16:01:40 +0000 (UTC)
commit fabbd59fd64e7c28f664fb3078ca5446d98decba
Author: Benjamin Berg <bberg redhat com>
Date: Mon Mar 25 09:58:29 2019 +0100
power: Fix potential manager reference count leak
The reference would be leaked if the function returns early. Move
attaching the data and register it so it gets unref'ed automatically.
Note that this reference leak has no effect in normal sessions, in the
worst case it prevents proper cleaup of some resources on daemon
shutdown.
plugins/power/gsd-power-manager.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index c544dc7d..8225ab0e 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -2799,8 +2799,6 @@ backlight_brightness_step_cb (GObject *object,
brightness,
gsd_backlight_get_connector
(backlight)));
}
-
- g_object_unref (manager);
}
/* Callback */
@@ -2830,8 +2828,6 @@ handle_method_call_screen (GsdPowerManager *manager,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
- g_object_set_data (G_OBJECT (invocation), "gsd-power-manager", g_object_ref (manager));
-
if (!manager->backlight) {
g_dbus_method_invocation_return_error_literal (invocation,
GSD_POWER_MANAGER_ERROR,
GSD_POWER_MANAGER_ERROR_NO_BACKLIGHT,
@@ -2839,6 +2835,8 @@ handle_method_call_screen (GsdPowerManager *manager,
return;
}
+ g_object_set_data_full (G_OBJECT (invocation), "gsd-power-manager", g_object_ref (manager),
g_object_unref);
+
if (g_strcmp0 (method_name, "StepUp") == 0) {
g_debug ("screen step up");
gsd_backlight_step_up_async (manager->backlight, NULL, backlight_brightness_step_cb,
invocation);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]