diff options
author | wm4 <wm4@nowhere> | 2015-02-20 18:53:35 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-02-20 18:53:35 +0100 |
commit | 9861abf8ffa4c9e7c4ad9a4f3f667e6f833624a3 (patch) | |
tree | 7f9e96d2f01c62402632c21f9ef1c58595b8a760 | |
parent | 885c2fff7091e9ea71cad8da56904ead73ca0853 (diff) | |
download | mpv-9861abf8ffa4c9e7c4ad9a4f3f667e6f833624a3.tar.bz2 mpv-9861abf8ffa4c9e7c4ad9a4f3f667e6f833624a3.tar.xz |
vo_opengl: minor robustness improvement in function loader
Check the scanf() return value, and don't continue if it doesn't find
both numbers (can happen with GLES 1.0). Also, some implementations can
return NULL from glGetString() if something is "broken".
-rw-r--r-- | video/out/gl_common.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 577b24abec..a059c4dc48 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -342,11 +342,15 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), int major = 0, minor = 0; const char *version_string = gl->GetString(GL_VERSION); + if (!version_string) + goto error; + mp_verbose(log, "GL_VERSION='%s'\n", version_string); if (strncmp(version_string, "OpenGL ES ", 10) == 0) { version_string += 10; gl->es = 100; } - sscanf(version_string, "%d.%d", &major, &minor); + if (sscanf(version_string, "%d.%d", &major, &minor) < 2) + goto error; gl->version = MPGL_VER(major, minor); mp_verbose(log, "Detected %s %d.%d.\n", gl->es ? "GLES" : "desktop OpenGL", major, minor); @@ -362,7 +366,6 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), mp_verbose(log, "GL_VENDOR='%s'\n", gl->GetString(GL_VENDOR)); mp_verbose(log, "GL_RENDERER='%s'\n", gl->GetString(GL_RENDERER)); - mp_verbose(log, "GL_VERSION='%s'\n", gl->GetString(GL_VERSION)); const char *shader = gl->GetString(GL_SHADING_LANGUAGE_VERSION); if (shader) mp_verbose(log, "GL_SHADING_LANGUAGE_VERSION='%s'\n", shader); |