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

Eric Engestrom eric.engestrom at imgtec.com
Thu Mar 2 10:53:15 UTC 2017


On Thursday, 2017-03-02 08:56:55 +0200, Tapani Pälli wrote:
> 
> On 03/02/2017 01:31 AM, Eric Engestrom wrote:
> > 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 " ");                        \
> 
> Doesn't this try to verify the same thing as previous assert, the length of
> the complete string? Maybe we should just add that ' ' character to the
> assert above and it should match the check?

After a bit of sleep, yeah, this checks essentially the same thing,
except this new assert checks the length if everything was enabled,
whereas the old one checks the length of what is currently enabled,
when testing.

v2 incoming, I'll just remove the first assert altogether as it wasn't
testing much (on top of being broken in a couple ways).

Cheers,
  Eric


> 
> 
> >     } 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
> >  }
> > 
> > 


More information about the mesa-dev mailing list