wayland: Don't free the Wayland display name string too early

We accidentally freed the Wayland display name string, meaning
retrieving it later retrieved freed memory.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
This commit is contained in:
Jonas Ådahl 2017-08-18 14:18:14 +08:00
parent 2a318eb3f2
commit dcd15e6145

View File

@ -321,6 +321,7 @@ meta_wayland_pre_clutter_init (void)
void void
meta_wayland_override_display_name (char *display_name) meta_wayland_override_display_name (char *display_name)
{ {
g_clear_pointer (&_display_name_override, g_free);
_display_name_override = g_strdup (display_name); _display_name_override = g_strdup (display_name);
} }
@ -367,13 +368,11 @@ meta_wayland_init (void)
if (_display_name_override) if (_display_name_override)
{ {
compositor->display_name = _display_name_override; compositor->display_name = g_steal_pointer (&_display_name_override);
if (wl_display_add_socket (compositor->wayland_display, if (wl_display_add_socket (compositor->wayland_display,
_display_name_override) != 0) compositor->display_name) != 0)
g_error ("Failed to create_socket"); g_error ("Failed to create_socket");
g_clear_pointer (&_display_name_override, g_free);
} }
else else
{ {
@ -407,6 +406,7 @@ meta_wayland_finalize (void)
compositor = meta_wayland_compositor_get_default (); compositor = meta_wayland_compositor_get_default ();
meta_xwayland_stop (&compositor->xwayland_manager); meta_xwayland_stop (&compositor->xwayland_manager);
g_clear_pointer (&compositor->display_name, g_free);
} }
void void