From dcd15e6145eba580ded666e0651c3c5fbcd1217a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 18 Aug 2017 14:18:14 +0800 Subject: [PATCH] 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 --- src/wayland/meta-wayland.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 965088221..716b7f331 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -321,6 +321,7 @@ meta_wayland_pre_clutter_init (void) void meta_wayland_override_display_name (char *display_name) { + g_clear_pointer (&_display_name_override, g_free); _display_name_override = g_strdup (display_name); } @@ -367,13 +368,11 @@ meta_wayland_init (void) 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, - _display_name_override) != 0) + compositor->display_name) != 0) g_error ("Failed to create_socket"); - - g_clear_pointer (&_display_name_override, g_free); } else { @@ -407,6 +406,7 @@ meta_wayland_finalize (void) compositor = meta_wayland_compositor_get_default (); meta_xwayland_stop (&compositor->xwayland_manager); + g_clear_pointer (&compositor->display_name, g_free); } void