summaryrefslogtreecommitdiffstats
path: root/src/glx
diff options
context:
space:
mode:
authorDaniel Czarnowski <daniel.czarnowski@intel.com>2016-02-10 09:36:05 -0800
committerTapani Pälli <tapani.palli@intel.com>2016-06-09 17:55:44 +0300
commitcf804b4455fac9e585b3600a8318caaced9c23de (patch)
treec4da8622281deeb9b8a9ef5361a8d69c2b638396 /src/glx
parent2d140ae70ac6ad69f39d427d95bd622d5640a1b7 (diff)
downloadexternal_mesa3d-cf804b4455fac9e585b3600a8318caaced9c23de.tar.gz
external_mesa3d-cf804b4455fac9e585b3600a8318caaced9c23de.tar.bz2
external_mesa3d-cf804b4455fac9e585b3600a8318caaced9c23de.zip
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>
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/glxcmds.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 38b9059458..3856032ce6 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -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,