diff --git a/src/posix_tls.c b/src/posix_tls.c index b3836744..f264f0ba 100644 --- a/src/posix_tls.c +++ b/src/posix_tls.c @@ -41,12 +41,14 @@ int _glfwCreateContextTLS(void) return GLFW_FALSE; } + _glfw.posix_tls.allocated = GLFW_TRUE; return GLFW_TRUE; } void _glfwDestroyContextTLS(void) { - pthread_key_delete(_glfw.posix_tls.context); + if (_glfw.posix_tls.allocated) + pthread_key_delete(_glfw.posix_tls.context); } void _glfwSetContextTLS(_GLFWwindow* context) diff --git a/src/posix_tls.h b/src/posix_tls.h index c653aad1..124f2145 100644 --- a/src/posix_tls.h +++ b/src/posix_tls.h @@ -37,6 +37,7 @@ // typedef struct _GLFWtlsPOSIX { + GLFWbool allocated; pthread_key_t context; } _GLFWtlsPOSIX;