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.

(cherry picked from commit 3bbb41eacc)
This commit is contained in:
Camilla Löwy 2022-06-10 15:45:07 +02:00
parent 608007673f
commit 1c4284e449
2 changed files with 5 additions and 1 deletions

View File

@ -161,6 +161,7 @@ information on what to include when reporting a bug.
- [Wayland] Bugfix: `glfwSetWindowSize` would resize a full screen window
- [Wayland] Bugfix: A window content scale event would be emitted every time
the window resized
- [Wayland] Bugfix: If `glfwInit` failed it would close stdin
## Contact

View File

@ -314,6 +314,10 @@ int _glfwPlatformInit(void)
long cursorSizeLong;
int cursorSize;
// These must be set before any failure checks
_glfw.wl.timerfd = -1;
_glfw.wl.cursorTimerfd = -1;
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
if (!_glfw.wl.cursor.handle)
{
@ -430,7 +434,6 @@ int _glfwPlatformInit(void)
_glfwInitTimerPOSIX();
_glfw.wl.timerfd = -1;
if (_glfw.wl.seatVersion >= 4)
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);