diff options
author | wm4 <wm4@nowhere> | 2015-03-25 12:36:31 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-25 12:36:36 +0100 |
commit | 6d9f15a8ab8a80d13a04c4fae5ce3f251aa20275 (patch) | |
tree | a6bc6b80d956404e1fbd1bf0c3f2e4f54b90a631 /video/out | |
parent | 85c21ae40940d6c54e36b5822e9ac1a517185b07 (diff) | |
download | mpv-6d9f15a8ab8a80d13a04c4fae5ce3f251aa20275.tar.bz2 mpv-6d9f15a8ab8a80d13a04c4fae5ce3f251aa20275.tar.xz |
vo_opengl: check extensions properly
With the previous commit, we have no need anymore to check a part of an
extension string (for ignoring a prefix). So check the extension string
properly, instead of just using the broken old strstr() method, which
could accidentally ignore prefixes or suffixes. Do this by extending
the check to whether the extension name is properly delimited by spaces
or string start/end.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gl_common.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 14d7649e8b..dbf5dbd277 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -79,6 +79,14 @@ static void GLAPIENTRY dummy_glBindFramebuffer(GLenum target, GLuint framebuffer assert(framebuffer == 0); } +static bool check_ext(GL *gl, const char *name) +{ + const char *exts = gl->extensions; + char *s = strstr(exts, name); + char *e = s ? s + strlen(name) : NULL; + return s && (s == exts || s[-1] == ' ') && (e[0] == ' ' || !e[0]); +} + #define FN_OFFS(name) offsetof(GL, name) #define DEF_FN(name) {FN_OFFS(name), {"gl" # name}} @@ -418,7 +426,7 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), if (ver_core) must_exist = version >= ver_core; - if (section->extension && strstr(gl->extensions, section->extension)) + if (section->extension && check_ext(gl, section->extension)) exists = true; exists |= must_exist; |