[OPENGL32]
authorJérôme Gardou <jerome.gardou@reactos.org>
Sat, 5 Mar 2011 16:23:30 +0000 (16:23 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Sat, 5 Mar 2011 16:23:30 +0000 (16:23 +0000)
  - Naive try to fix bug 5057

svn path=/trunk/; revision=50973

reactos/dll/win32/opengl32/opengl32.c

index cf46007..1d5330a 100644 (file)
@@ -72,7 +72,7 @@ static void
 OPENGL32_ThreadDetach( void )
 {
     GLTHREADDATA* lpData = NULL;
-    PROC *dispatchTable = NULL;
+       TEB* teb = NtCurrentTeb();
 
     rosglMakeCurrent( NULL, NULL );
 
@@ -85,12 +85,15 @@ OPENGL32_ThreadDetach( void )
         lpData = NULL;
     }
 
-    dispatchTable = NtCurrentTeb()->glTable;
-    if (dispatchTable != NULL)
+    if (teb->glTable != NULL)
     {
-        if (!HeapFree( GetProcessHeap(), 0, dispatchTable ))
+        if (!HeapFree( GetProcessHeap(), 0, teb->glTable ))
+               {
             DBGPRINT( "Warning: HeapFree() on dispatch table failed (%d)",
                       GetLastError() );
+               }
+               /* NULL-ify it. Even if something went wrong, it's not a good idea to keep it non NULL */
+               teb->glTable = NULL;
     }
 }