Fix glfwMakeContextCurrent using uninitialized TLS

Issue reported by danhambleton on the GLFW forum:
https://discourse.glfw.org/t/posix-thread-local-storage-tls-error-when-making-context-current/2034
This commit is contained in:
Camilla Löwy 2022-04-08 18:22:39 +02:00
parent 4cb36872a5
commit f843d53333
3 changed files with 5 additions and 1 deletions

View File

@ -44,6 +44,7 @@ video tutorials.
- Noel Cower
- CuriouserThing
- Jason Daly
- danhambleton
- Jarrod Davis
- Olivier Delannoy
- Paul R. Deppe

View File

@ -172,6 +172,7 @@ information on what to include when reporting a bug.
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
incompatible controllers sharing hardware ID (#1763)
- Bugfix: Native access functions for context handles did not check that the API matched
- Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
to the window menu
- [Win32] Added a version info resource to the GLFW DLL

View File

@ -609,10 +609,12 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot);
_GLFWwindow* previous;
_GLFW_REQUIRE_INIT();
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
if (window && window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,