stw/wgl: add null context check in wglBindTexImageARB()
authorBrian Paul <brianp@vmware.com>
Mon, 10 Oct 2016 21:54:09 +0000 (15:54 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 31 Mar 2017 19:30:53 +0000 (13:30 -0600)
To avoid dereferencing a null pointer in case wglMakeCurrent() wasn't
called.  Found while debugging SWKOTOR game.

Reviewed-by: Neha Bhende <bhenden@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/state_trackers/wgl/stw_ext_rendertexture.c

index 5eeb0df21f18d185af72ff36642e1036ea11f9a5..9d766966771ffe44561c084822dcfffac24d0aa1 100644 (file)
@@ -129,6 +129,12 @@ wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuffer)
     * we do here.
     */
 
+   if (!curctx) {
+      debug_printf("No rendering context in wglBindTexImageARB()\n");
+      SetLastError(ERROR_INVALID_OPERATION);
+      return FALSE;
+   }
+
    fb = stw_framebuffer_from_HPBUFFERARB(hPbuffer);
    if (!fb) {
       debug_printf("Invalid pbuffer handle in wglBindTexImageARB()\n");