mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 10:30:13 +01:00
glx: fix crash with bad fbconfig
GLX documentation states:
glXCreateNewContext can generate the following errors: (...)
GLXBadFBConfig if config is not a valid GLXFBConfig
Function checks if the given config is a valid config and sets proper
error code.
Fixes currently crashing glx-fbconfig-bad Piglit test.
v2: coding style cleanups (Emil, Topi)
use DefaultScreen macro (Emil)
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Cc: "11.2" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
parent
2d140ae70a
commit
cf804b4455
1 changed files with 23 additions and 0 deletions
|
|
@ -1630,6 +1630,29 @@ glXCreateNewContext(Display * dpy, GLXFBConfig fbconfig,
|
|||
int renderType, GLXContext shareList, Bool allowDirect)
|
||||
{
|
||||
struct glx_config *config = (struct glx_config *) fbconfig;
|
||||
int screen = DefaultScreen(dpy);
|
||||
struct glx_config **config_list;
|
||||
int list_size;
|
||||
unsigned i;
|
||||
|
||||
if (!config) {
|
||||
__glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateNewContext, false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
config_list = (struct glx_config **)
|
||||
glXGetFBConfigs(dpy, screen, &list_size);
|
||||
|
||||
for (i = 0; i < list_size; i++) {
|
||||
if (config_list[i] == config)
|
||||
break;
|
||||
}
|
||||
free(config_list);
|
||||
|
||||
if (i == list_size) {
|
||||
__glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateNewContext, false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return CreateContext(dpy, config->fbconfigID, config, shareList,
|
||||
allowDirect, X_GLXCreateNewContext, renderType,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue