[PATCH 2/2] opengl32: Check for valid context in wglGetProcAddress

Roderick Colenbrander thunderbird2k at gmail.com
Mon Jun 25 00:42:11 CDT 2012


---
 dlls/opengl32/tests/opengl.c |    2 +-
 dlls/opengl32/wgl.c          |   11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index ffc676e..c18b0ad 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -797,7 +797,7 @@ static void test_getprocaddress(HDC hdc)
     /* Temporarily disable the context, so we can see that we can't retrieve functions now. */
     wglMakeCurrent(hdc, NULL);
     func = wglGetProcAddress("glActiveTextureARB");
-    todo_wine ok(func == NULL, "Function lookup without a context passed, expected a failure; last error %#x\n", GetLastError());
+    ok(func == NULL, "Function lookup without a context passed, expected a failure; last error %#x\n", GetLastError());
     wglMakeCurrent(hdc, ctx);
 }
 
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 98b04d4..9200dd6 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -300,9 +300,18 @@ PROC WINAPI wglGetProcAddress(LPCSTR  lpszProc) {
 
   TRACE("(%s)\n", lpszProc);
 
-  if(lpszProc == NULL)
+  if (lpszProc == NULL)
     return NULL;
 
+  /* Without an active context opengl32 doesn't know to what
+   * driver it has to dispatch wglGetProcAddress.
+   */
+  if (wglGetCurrentContext() == NULL)
+  {
+    WARN("No active WGL context found\n");
+    return NULL;
+  }
+
   /* First, look if it's not already defined in the 'standard' OpenGL functions */
   if ((local_func = GetProcAddress(opengl32_handle, lpszProc)) != NULL) {
     TRACE(" found function in 'standard' OpenGL functions (%p)\n", local_func);
-- 
1.7.10.2




More information about the wine-patches mailing list