Mesa (7.8-gles): egl: Only allow valid config attributes in _eglParseConfigAttribList()

Kristian Høgsberg krh at kemper.freedesktop.org
Fri May 14 19:23:46 UTC 2010


Module: Mesa
Branch: 7.8-gles
Commit: f2e8f4c473036c2277aa972fa6c9ac7a4cca0449
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2e8f4c473036c2277aa972fa6c9ac7a4cca0449

Author: Kristian Høgsberg <krh at bitplanet.net>
Date:   Fri May 14 12:07:38 2010 -0400

egl: Only allow valid config attributes in _eglParseConfigAttribList()

Passing 0x3030, 0 in the chooser list didn't get caught.

---

 src/egl/main/eglconfig.c |   52 +++++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index 47513a4..a659d19 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.
  */




More information about the mesa-commit mailing list