summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2010-05-14 12:07:38 -0400
committerKristian Høgsberg <[email protected]>2010-05-14 14:47:54 -0400
commit554e4fc26a64a90012b0d7dcc1205441273f214c (patch)
treec63379dd6a9a732914d121da1f82fcc5fe723b01 /src/egl
parentc1423e34f910026d1c37a64e64d15277a4dd1258 (diff)
egl: Only allow valid config attributes in _eglParseConfigAttribList()
Passing 0x3030, 0 in the chooser list didn't get caught.
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/main/eglconfig.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index 47513a4edb2..a659d19c373 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -478,6 +478,26 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria)
return matched;
}
+static INLINE EGLBoolean
+_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
+{
+ if (_eglIndexConfig(conf, attr) < 0)
+ return EGL_FALSE;
+
+ /* there are some holes in the range */
+ switch (attr) {
+ case 0x3030 /* a gap before EGL_SAMPLES */:
+ case EGL_NONE:
+#ifdef EGL_VERSION_1_4
+ case EGL_MATCH_NATIVE_PIXMAP:
+#endif
+ return EGL_FALSE;
+ default:
+ break;
+ }
+
+ return EGL_TRUE;
+}
/**
* Initialize a criteria config from the given attribute list.
@@ -500,15 +520,13 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list)
/* parse the list */
for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i += 2) {
- EGLint idx;
-
attr = attrib_list[i];
val = attrib_list[i + 1];
- idx = _eglIndexConfig(conf, attr);
- if (idx < 0)
- return EGL_FALSE;
- conf->Storage[idx] = val;
+ if (!_eglIsConfigAttribValid(conf, attr))
+ return EGL_FALSE;
+
+ SET_CONFIG_ATTRIB(conf, attr, val);
/* rememeber some attributes for post-processing */
switch (attr) {
@@ -781,28 +799,6 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
}
-static INLINE EGLBoolean
-_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
-{
- if (_eglIndexConfig(conf, attr) < 0)
- return EGL_FALSE;
-
- /* there are some holes in the range */
- switch (attr) {
- case 0x3030 /* a gap before EGL_SAMPLES */:
- case EGL_NONE:
-#ifdef EGL_VERSION_1_4
- case EGL_MATCH_NATIVE_PIXMAP:
-#endif
- return EGL_FALSE;
- default:
- break;
- }
-
- return EGL_TRUE;
-}
-
-
/**
* Fallback for eglGetConfigAttrib.
*/