Commit 5261d14d authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Matthias Clasen
Browse files

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
parent f0b4779d
......@@ -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;
}
......@@ -856,21 +875,6 @@ init_xfree_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 void
deinit_multihead (GdkScreen *screen)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment