From: Brian Paul Date: Thu, 16 Feb 2012 19:20:57 +0000 (-0700) Subject: st/wgl: check for hPbuffer=0 in wgl pbuffer functions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=be05388ce983face72ca17241f0f2e154c11f435;p=mesa.git st/wgl: check for hPbuffer=0 in wgl pbuffer functions Per the GL_WGL_pbuffer spec, generate ERROR_INVALID_HANDLE and return FALSE (and don't segfault). Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c index 085591a5560..7596cb6bd95 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c +++ b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c @@ -239,6 +239,11 @@ wglGetPbufferDCARB(HPBUFFERARB hPbuffer) struct stw_framebuffer *fb; HDC hDC; + if (!hPbuffer) { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + fb = (struct stw_framebuffer *)hPbuffer; hDC = GetDC(fb->hWnd); @@ -255,6 +260,11 @@ wglReleasePbufferDCARB(HPBUFFERARB hPbuffer, { struct stw_framebuffer *fb; + if (!hPbuffer) { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + fb = (struct stw_framebuffer *)hPbuffer; return ReleaseDC(fb->hWnd, hDC); @@ -266,6 +276,11 @@ wglDestroyPbufferARB(HPBUFFERARB hPbuffer) { struct stw_framebuffer *fb; + if (!hPbuffer) { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + fb = (struct stw_framebuffer *)hPbuffer; /* This will destroy all our data */ @@ -280,6 +295,11 @@ wglQueryPbufferARB(HPBUFFERARB hPbuffer, { struct stw_framebuffer *fb; + if (!hPbuffer) { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + fb = (struct stw_framebuffer *)hPbuffer; switch (iAttribute) {