From d79afa805510b45c823e7ca979a6486278dca41d Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 28 Jan 2024 17:45:03 +0000 Subject: [PATCH] Win32: Minor changes to disabled cursor fix over RDP - Use _glfw_calloc and _glfw_free - Exit from _glfwInitWin32 with error if we fail to create a blank cursor on a remote session --- src/win32_init.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index a44e8145..739c9c33 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -438,8 +438,8 @@ static void createBlankCursor(void) // using SetCursorPos when connected over RDP int cursorWidth = GetSystemMetrics(SM_CXCURSOR); int cursorHeight = GetSystemMetrics(SM_CYCURSOR); - unsigned char* andMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); - unsigned char* xorMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); + unsigned char* andMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); + unsigned char* xorMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); if (andMask != NULL && xorMask != NULL) { @@ -449,8 +449,8 @@ static void createBlankCursor(void) // which serves as an acceptable fallback blank cursor (other than on RDP) _glfw.win32.blankCursor = CreateCursor(NULL, 0, 0, cursorWidth, cursorHeight, andMask, xorMask); - free(andMask); - free(xorMask); + _glfw_free(andMask); + _glfw_free(xorMask); } } @@ -740,6 +740,12 @@ int _glfwInitWin32(void) //Some hacks are needed to support Remote Desktop... initRemoteSession(); + if (_glfw.win32.isRemoteSession && _glfw.win32.blankCursor == NULL ) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, + "Win32: Failed to create blank cursor for remote session."); + return GLFW_FALSE; + } _glfwPollMonitorsWin32(); return GLFW_TRUE;