[gtk+] Fix memory leak in gdkscreen-x11
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+] Fix memory leak in gdkscreen-x11
- Date: Fri, 10 Apr 2009 00:14:53 -0400 (EDT)
commit 5261d14d6fe77972b8dde6b647486437715fb353
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Fri Apr 10 00:14:23 2009 -0400
Fix memory leak in gdkscreen-x11
When RandR 1.2 X driver doesn't return any usable multihead data the
monitors array is freed, without freeing the memory allocated by the array
elements before. Fixes bug #578354
---
gdk/x11/gdkscreen-x11.c | 36 ++++++++++++++++++++----------------
1 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 0bcb2bc..a2eacea 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -663,6 +663,21 @@ init_fake_xinerama (GdkScreen *screen)
return FALSE;
}
+static void
+free_monitors (GdkX11Monitor *monitors,
+ gint n_monitors)
+{
+ int i;
+
+ for (i = 0; i < n_monitors; ++i)
+ {
+ g_free (monitors[i].output_name);
+ g_free (monitors[i].manufacturer);
+ }
+
+ g_free (monitors);
+}
+
static int
monitor_compare_function (GdkX11Monitor *monitor1,
GdkX11Monitor *monitor2)
@@ -753,7 +768,11 @@ init_randr13 (GdkScreen *screen)
/* non RandR 1.2 X driver doesn't return any usable multihead data */
if (randr12_compat)
{
- g_array_free (monitors, TRUE);
+ guint n_monitors = monitors->len;
+
+ free_monitors ((GdkX11Monitor *)g_array_free (monitors, FALSE),
+ n_monitors);
+
return FALSE;
}
@@ -857,21 +876,6 @@ init_xfree_xinerama (GdkScreen *screen)
}
static void
-free_monitors (GdkX11Monitor *monitors,
- gint n_monitors)
-{
- int i;
-
- for (i = 0; i < n_monitors; ++i)
- {
- g_free (monitors[i].output_name);
- g_free (monitors[i].manufacturer);
- }
-
- g_free (monitors);
-}
-
-static void
deinit_multihead (GdkScreen *screen)
{
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]