mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 05:36:35 +00:00
Don't delete the POSIX TLS key if it hasn't been created yet
0 (the initial value of context) is a valid TLS key, so doing this can delete someone else's key.
This commit is contained in:
parent
43f4afef78
commit
7b6985f033
@ -41,12 +41,17 @@ int _glfwCreateContextTLS(void)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfw.posix_tls.allocated = GLFW_TRUE;
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwDestroyContextTLS(void)
|
void _glfwDestroyContextTLS(void)
|
||||||
|
{
|
||||||
|
if (_glfw.posix_tls.allocated)
|
||||||
{
|
{
|
||||||
pthread_key_delete(_glfw.posix_tls.context);
|
pthread_key_delete(_glfw.posix_tls.context);
|
||||||
|
_glfw.posix_tls.allocated = GLFW_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwSetContextTLS(_GLFWwindow* context)
|
void _glfwSetContextTLS(_GLFWwindow* context)
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
//
|
//
|
||||||
typedef struct _GLFWtlsPOSIX
|
typedef struct _GLFWtlsPOSIX
|
||||||
{
|
{
|
||||||
|
GLFWbool allocated;
|
||||||
pthread_key_t context;
|
pthread_key_t context;
|
||||||
|
|
||||||
} _GLFWtlsPOSIX;
|
} _GLFWtlsPOSIX;
|
||||||
|
Loading…
Reference in New Issue
Block a user