Преглед на файлове

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
Camilla Löwy преди 3 години
родител
ревизия
f843d53333
променени са 3 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 1 0
      CONTRIBUTORS.md
  2. 1 0
      README.md
  3. 3 1
      src/context.c

+ 1 - 0
CONTRIBUTORS.md

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

+ 1 - 0
README.md

@@ -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

+ 3 - 1
src/context.c

@@ -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,