[Mesa-dev] [PATCH mesa 4/5] egl: add assert on the max length of the extension string

Eric Engestrom eric at engestrom.ch
Wed Mar 1 23:31:53 UTC 2017


Signed-off-by: Eric Engestrom <eric at engestrom.ch>
---
 src/egl/main/eglapi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 274dcde01d..2d7077f88b 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -467,6 +467,7 @@ _eglAppendExtension(char **str, const char *ext)
 static void
 _eglCreateExtensionsString(_EGLDisplay *dpy)
 {
+   unsigned max_extstr_length = 0;
 #define _EGL_CHECK_EXTENSION(ext)                                          \
    do {                                                                    \
       if (dpy->Extensions.ext) {                                           \
@@ -474,6 +475,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
                 dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN);          \
          _eglAppendExtension(&exts, "EGL_" #ext);                          \
       }                                                                    \
+      max_extstr_length += strlen("EGL_" #ext " ");                        \
    } while (0)
 
    char *exts = dpy->ExtensionsString;
@@ -527,6 +529,8 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
    _EGL_CHECK_EXTENSION(WL_bind_wayland_display);
    _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image);
 
+   assert(max_extstr_length < _EGL_MAX_EXTENSIONS_LEN);
+
 #undef _EGL_CHECK_EXTENSION
 }
 
-- 
Cheers,
  Eric



More information about the mesa-dev mailing list