From 807658e9725bd8d3693e3a7178c72546b8835e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 4 Sep 2017 12:32:53 +0800 Subject: [PATCH] wayland: Don't free non-transferred string when cleaning up When cleaning up the display name string management, the display name string retrieved from libwayland-server was also passed to free() on clean up. This is invalid as the display name string ownership is not transferred to us. Fix this by strdup:ing the string before saving it. https://bugzilla.gnome.org/show_bug.cgi?id=730551 --- src/wayland/meta-wayland.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 716b7f331..2c3dff281 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -376,10 +376,13 @@ meta_wayland_init (void) } else { - compositor->display_name = - wl_display_add_socket_auto (compositor->wayland_display); - if (compositor->display_name == NULL) + const char *display_name; + + display_name = wl_display_add_socket_auto (compositor->wayland_display); + if (!display_name) g_error ("Failed to create socket"); + + compositor->display_name = g_strdup (display_name); } set_gnome_env ("DISPLAY", meta_wayland_get_xwayland_display_name (compositor));