From be05388ce983face72ca17241f0f2e154c11f435 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 16 Feb 2012 12:20:57 -0700 Subject: 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 --- src/gallium/state_trackers/wgl/stw_ext_pbuffer.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/gallium/state_trackers/wgl') 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) { -- cgit v1.2.3