Wayland: Fix glfwInit closing stdin on failure

If platform initialization failed before either timer fd member had been
set to -1 or a valid fd, termination would close stdin.
This commit is contained in:
Camilla Löwy
2022-06-10 15:45:07 +02:00
parent 0b76e3a6f1
commit 3bbb41eacc
2 changed files with 5 additions and 1 deletions

View File

@@ -479,6 +479,10 @@ int _glfwInitWayland(void)
long cursorSizeLong;
int cursorSize;
// These must be set before any failure checks
_glfw.wl.timerfd = -1;
_glfw.wl.cursorTimerfd = -1;
_glfw.wl.client.display_flush = (PFN_wl_display_flush)
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush");
_glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read)
@@ -635,7 +639,6 @@ int _glfwInitWayland(void)
// Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display);
_glfw.wl.timerfd = -1;
if (_glfw.wl.seatVersion >= 4)
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);