diff --git a/glfw/cocoa_monitor.m b/glfw/cocoa_monitor.m index 70d64e116..fbd01d3d8 100644 --- a/glfw/cocoa_monitor.m +++ b/glfw/cocoa_monitor.m @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -635,6 +636,8 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay); return monitor->ns.displayID; } diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 0cbc95acc..74fcc4e36 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -35,6 +35,7 @@ #import #include #include +#include #define debug debug_rendering @@ -3127,6 +3128,8 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(nil); return window->ns.object; } diff --git a/glfw/egl_context.c b/glfw/egl_context.c index b4da38a8c..63198262b 100644 --- a/glfw/egl_context.c +++ b/glfw/egl_context.c @@ -790,6 +790,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void) GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); if (window->context.client == GLFW_NO_API) @@ -804,6 +806,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); if (window->context.client == GLFW_NO_API) diff --git a/glfw/glx_context.c b/glfw/glx_context.c index 849ff910a..48faafc8f 100644 --- a/glfw/glx_context.c +++ b/glfw/glx_context.c @@ -658,6 +658,8 @@ bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig UNUSED, GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (window->context.client == GLFW_NO_API) @@ -672,6 +674,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); if (window->context.client == GLFW_NO_API) diff --git a/glfw/nsgl_context.m b/glfw/nsgl_context.m index 69b656b21..c4c9a739c 100644 --- a/glfw/nsgl_context.m +++ b/glfw/nsgl_context.m @@ -27,6 +27,7 @@ //======================================================================== #include "internal.h" +#include static void makeContextCurrentNSGL(_GLFWwindow* window) @@ -319,6 +320,8 @@ bool _glfwCreateContextNSGL(_GLFWwindow* window, GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (window->context.client == GLFW_NO_API) diff --git a/glfw/osmesa_context.c b/glfw/osmesa_context.c index c689b3b31..e688cbe26 100644 --- a/glfw/osmesa_context.c +++ b/glfw/osmesa_context.c @@ -352,6 +352,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (window->context.client == GLFW_NO_API) diff --git a/glfw/wl_monitor.c b/glfw/wl_monitor.c index f58cb3efb..f1be0f4b4 100644 --- a/glfw/wl_monitor.c +++ b/glfw/wl_monitor.c @@ -28,10 +28,10 @@ #include "internal.h" -#include #include #include #include +#include static void outputHandleGeometry(void* data, @@ -241,6 +241,8 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor UNUSED, GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return monitor->wl.output; } diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 247397d66..60fb60881 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -40,6 +40,7 @@ #include #include #include +#include #define debug debug_rendering @@ -2869,6 +2870,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void) GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return window->wl.surface; } diff --git a/glfw/x11_monitor.c b/glfw/x11_monitor.c index 4c1a67d1e..aa7cc0ddb 100644 --- a/glfw/x11_monitor.c +++ b/glfw/x11_monitor.c @@ -33,6 +33,7 @@ #include #include #include +#include // Check whether the display mode should be included in enumeration @@ -593,6 +594,8 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); return monitor->x11.crtc; } @@ -600,6 +603,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); return monitor->x11.output; } diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 3e25361bb..471b9d8a8 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -41,6 +41,7 @@ #include #include #include +#include // Action for EWMH client messages #define _NET_WM_STATE_REMOVE 0 @@ -3408,6 +3409,8 @@ GLFWAPI Display* glfwGetX11Display(void) GLFWAPI unsigned long glfwGetX11Window(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); return window->x11.handle; }