From f0557e77a3e9551acc2e078cf10dfbd0e4d655e4 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Mon, 11 Dec 2017 18:48:13 +0000 Subject: [PATCH] Workaround gcc segfault (Fixes #97) --- .../frontend/wayland/wayland_connector.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/server/frontend/wayland/wayland_connector.cpp b/src/server/frontend/wayland/wayland_connector.cpp index 5866866f58b..1b39d13eb00 100644 --- a/src/server/frontend/wayland/wayland_connector.cpp +++ b/src/server/frontend/wayland/wayland_connector.cpp @@ -2313,22 +2313,20 @@ int mf::WaylandConnector::client_socket_fd() const enum { server, client, size }; int socket_fd[size]; + char const* error = nullptr; + if (socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fd)) { - BOOST_THROW_EXCEPTION((std::system_error{ - errno, - std::system_category(), - "Could not create socket pair"})); + error = "Could not create socket pair"; } - - if (!wl_client_create(display.get(), socket_fd[server])) + else if (!wl_client_create(display.get(), socket_fd[server])) { - BOOST_THROW_EXCEPTION((std::system_error{ - errno, - std::system_category(), - "Failed to add server end of socketpair to Wayland display"})); + error = "Failed to add server end of socketpair to Wayland display"; } + if (error) + BOOST_THROW_EXCEPTION((std::system_error{errno, std::system_category(), error})); + return socket_fd[client]; }