From a5faef330e5840f9bf46462000c41607d1194540 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Wed, 29 Jan 2014 11:01:00 -0500 Subject: [PATCH] display: fix memory leak if AddUserAuthentication called more than once Noted on downstream bug: https://bugzilla.redhat.com/show_bug.cgi?id=1020885 --- daemon/gdm-display.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c index b1adae8..352dd92 100644 --- a/daemon/gdm-display.c +++ b/daemon/gdm-display.c @@ -198,61 +198,68 @@ gdm_display_real_create_authority (GdmDisplay *display) display->priv->access_file = access_file; return TRUE; } gboolean gdm_display_create_authority (GdmDisplay *display) { gboolean ret; g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE); g_object_ref (display); ret = GDM_DISPLAY_GET_CLASS (display)->create_authority (display); g_object_unref (display); return ret; } static gboolean gdm_display_real_add_user_authorization (GdmDisplay *display, const char *username, char **filename, GError **error) { GdmDisplayAccessFile *access_file; GError *access_file_error; gboolean res; g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE); - g_return_val_if_fail (display->priv->access_file != NULL, FALSE); + + if (display->priv->user_access_file != NULL) { + g_set_error (error, + G_DBUS_ERROR, + G_DBUS_ERROR_ACCESS_DENIED, + "user access already assigned"); + return FALSE; + } g_debug ("GdmDisplay: Adding user authorization for %s", username); access_file_error = NULL; access_file = _create_access_file_for_user (display, username, &access_file_error); if (access_file == NULL) { g_propagate_error (error, access_file_error); return FALSE; } res = gdm_display_access_file_add_display_with_cookie (access_file, display, display->priv->x11_cookie, display->priv->x11_cookie_size, &access_file_error); if (! res) { g_debug ("GdmDisplay: Unable to add user authorization for %s: %s", username, access_file_error->message); g_propagate_error (error, access_file_error); gdm_display_access_file_close (access_file); g_object_unref (access_file); return FALSE; } *filename = gdm_display_access_file_get_path (access_file); display->priv->user_access_file = access_file; -- 1.8.4.2