From 7753f040facc89de4dacc33f9407a4fa334bf58c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 10 Oct 2016 15:54:09 -0600 Subject: [PATCH] stw/wgl: add null context check in wglBindTexImageARB() To avoid dereferencing a null pointer in case wglMakeCurrent() wasn't called. Found while debugging SWKOTOR game. Reviewed-by: Neha Bhende Reviewed-by: Charmaine Lee --- src/gallium/state_trackers/wgl/stw_ext_rendertexture.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/state_trackers/wgl/stw_ext_rendertexture.c b/src/gallium/state_trackers/wgl/stw_ext_rendertexture.c index 5eeb0df21f1..9d766966771 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_rendertexture.c +++ b/src/gallium/state_trackers/wgl/stw_ext_rendertexture.c @@ -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"); -- 2.30.2