Blob Blame History Raw
From 9b8c21080286f943d0a19431bc8c0061f4833443 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 30 Aug 2018 13:04:56 -0400
Subject: [PATCH 22/51] common: remove unnecessary free

This commit drops an erroneous free call, that would
potentially free a dangling pointer.

Luckily the error condition can never occur because the
error code checked is never returned, so the free call
is dead code.

This commit removes the free call.  A subsequent commit
will fix the error code checking.
---
 common/gdm-common.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/common/gdm-common.c b/common/gdm-common.c
index 59317a889..c909aceee 100644
--- a/common/gdm-common.c
+++ b/common/gdm-common.c
@@ -391,64 +391,62 @@ gdm_activate_session_by_id (GDBusConnection *connection,
         return TRUE;
 }
 
 gboolean
 gdm_get_login_window_session_id (const char  *seat_id,
 		                 char       **session_id)
 {
         gboolean   ret;
         int        res, i;
         char     **sessions;
         char      *service_id;
         char      *service_class;
         char      *state;
 
         res = sd_seat_get_sessions (seat_id, &sessions, NULL, NULL);
         if (res < 0) {
                 g_debug ("Failed to determine sessions: %s", strerror (-res));
                 return FALSE;
         }
 
         if (sessions == NULL || sessions[0] == NULL) {
                 *session_id = NULL;
                 ret = FALSE;
                 goto out;
         }
 
         for (i = 0; sessions[i]; i ++) {
 
                 res = sd_session_get_class (sessions[i], &service_class);
                 if (res < 0) {
-                        if (res == -ENOENT) {
-                                free (service_class);
+                        if (res == -ENOENT)
                                 continue;
-                        }
 
                         g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res));
                         ret = FALSE;
                         goto out;
                 }
 
                 if (strcmp (service_class, "greeter") != 0) {
                         free (service_class);
                         continue;
                 }
 
                 free (service_class);
 
                 ret = sd_session_get_state (sessions[i], &state);
                 if (ret < 0) {
                         g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res));
                         ret = FALSE;
                         goto out;
                 }
 
                 if (g_strcmp0 (state, "closing") == 0) {
                         free (state);
                         continue;
                 }
                 free (state);
 
                 res = sd_session_get_service (sessions[i], &service_id);
                 if (res < 0) {
                         g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res));
                         ret = FALSE;
-- 
2.27.0