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
This commit is contained in:
Jonas Ådahl 2017-09-04 12:32:53 +08:00
parent 8499a29d0a
commit 807658e972

View File

@ -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));