From 1d6215726807e73fd21da9a4a09c28aab3111879 Mon Sep 17 00:00:00 2001 From: "A. Tombs" Date: Tue, 28 May 2019 01:24:18 +0100 Subject: [PATCH] Win32: Cleanup pointer test in win32_window.c MSVC 2019 complains that the code at line 1744 (`GetMonitorInfo(window->monitor->win32.handle, &mi);`) can potentially dereference a null pointer. The compiler is wrong in this case (it has not spotted that `monitor` and `window->monitor` must be equal), but I think it makes sense for our non-NULL test to be on the variable we actually use rather than the one it was set from. Related to #1491. --- src/win32_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_window.c b/src/win32_window.c index b8d0dc3d..24966bf4 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1725,7 +1725,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _glfwInputWindowMonitor(window, monitor); - if (monitor) + if (window->monitor) { MONITORINFO mi = { sizeof(mi) }; UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;