[mutter] MetaMonitorManageKms: plug a GArray leak



commit 89672fad044885ece06eed68305dc0f480abbc0f
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri Oct 14 18:23:24 2016 +0200

    MetaMonitorManageKms: plug a GArray leak
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773116

 src/backends/native/meta-monitor-manager-kms.c |   20 ++++----------------
 1 files changed, 4 insertions(+), 16 deletions(-)
---
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
index 07671f7..2067f31 100644
--- a/src/backends/native/meta-monitor-manager-kms.c
+++ b/src/backends/native/meta-monitor-manager-kms.c
@@ -1531,31 +1531,19 @@ get_crtc_connectors (MetaMonitorManager *manager,
                      uint32_t          **connectors,
                      unsigned int       *n_connectors)
 {
-  GArray *connectors_array = NULL;
   unsigned int i;
+  GArray *connectors_array = g_array_new (FALSE, FALSE, sizeof (uint32_t));
 
   for (i = 0; i < manager->n_outputs; i++)
     {
       MetaOutput *output = &manager->outputs[i];
 
       if (output->crtc == crtc)
-        {
-          if (!connectors_array)
-            connectors_array = g_array_new (FALSE, FALSE, sizeof (uint32_t));
-          g_array_append_val (connectors_array, output->winsys_id);
-        }
+        g_array_append_val (connectors_array, output->winsys_id);
     }
 
-  if (connectors_array)
-    {
-      *connectors = (uint32_t *) connectors_array->data;
-      *n_connectors = connectors_array->len;
-    }
-  else
-    {
-      *connectors = NULL;
-      *n_connectors = 0;
-    }
+  *n_connectors = connectors_array->len;
+  *connectors = (uint32_t *) g_array_free (connectors_array, FALSE);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]