wine/dlls/opengl32 wgl.c
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Nov 30 14:54:38 CST 2005
ChangeSet ID: 21571
CVSROOT: /opt/cvs-commit
Module name: wine
Changes by: julliard at winehq.org 2005/11/30 14:54:38
Modified files:
dlls/opengl32 : wgl.c
Log message:
Raphael Junqueira <fenix at club-internet.fr>
Added some checks on wglCreatContext to avoid problems (and
SetLastErrors).
Patch: http://cvs.winehq.org/patch.py?id=21571
Old revision New revision Changes Path
1.68 1.69 +22 -11 wine/dlls/opengl32/wgl.c
Index: wine/dlls/opengl32/wgl.c
diff -u -p wine/dlls/opengl32/wgl.c:1.68 wine/dlls/opengl32/wgl.c:1.69
--- wine/dlls/opengl32/wgl.c:1.68 30 Nov 2005 20:54:38 -0000
+++ wine/dlls/opengl32/wgl.c 30 Nov 2005 20:54:38 -0000
@@ -165,6 +165,8 @@ HGLRC WINAPI wglCreateContext(HDC hdc)
int num;
XVisualInfo template;
Display *display = get_display( hdc );
+ int hdcPF = GetPixelFormat(hdc);
+ GLXFBConfig cur_cfg;
TRACE("(%p)\n", hdc);
@@ -178,37 +180,46 @@ HGLRC WINAPI wglCreateContext(HDC hdc)
/* Need to set errors here */
return NULL;
}
-
- /* The context will be allocated in the wglMakeCurrent call */
- ENTER_GL();
- ret = alloc_context();
- LEAVE_GL();
- ret->hdc = hdc;
- ret->display = display;
- ret->vis = vis;
+ if (0 >= hdcPF) {
+ SetLastError(ERROR_INVALID_PIXEL_FORMAT);
+ return NULL;
+ }
{
- int hdcPF = GetPixelFormat(hdc);
int nCfgs_fmt = 0;
GLXFBConfig* cfgs_fmt = NULL;
- GLXFBConfig cur_cfg;
int value;
int gl_test = 0;
cfgs_fmt = glXGetFBConfigs(display, DefaultScreen(display), &nCfgs_fmt);
if (NULL == cfgs_fmt || 0 == nCfgs_fmt) {
ERR("Cannot get FB Configs, expect problems.\n");
+ SetLastError(ERROR_INVALID_PIXEL_FORMAT);
+ return NULL;
+ }
+ if (nCfgs_fmt < hdcPF) {
+ ERR("(%p): unexpected pixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, hdcPF, nCfgs_fmt);
+ SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
cur_cfg = cfgs_fmt[hdcPF - 1];
gl_test = glXGetFBConfigAttrib(display, cur_cfg, GLX_FBCONFIG_ID, &value);
if (gl_test) {
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
+ SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
- ret->fb_conf = cur_cfg;
XFree(cfgs_fmt);
}
+ /* The context will be allocated in the wglMakeCurrent call */
+ ENTER_GL();
+ ret = alloc_context();
+ LEAVE_GL();
+ ret->hdc = hdc;
+ ret->display = display;
+ ret->vis = vis;
+ ret->fb_conf = cur_cfg;
+
TRACE(" creating context %p (GL context creation delayed)\n", ret);
return (HGLRC) ret;
}
More information about the wine-cvs
mailing list