summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-20 18:53:35 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-02-21 20:48:43 +0900
commit7ace4f2115db999105c31714ee7aa1b0099c6866 (patch)
tree9a7ddfb3abc094cc33c7e2a510335c7a90af6884
parentf67dfcbec60e6456059f0ff748b3e84bae18c13f (diff)
downloadmpv-7ace4f2115db999105c31714ee7aa1b0099c6866.tar.bz2
mpv-7ace4f2115db999105c31714ee7aa1b0099c6866.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". (cherry picked from commit 9861abf8ffa4c9e7c4ad9a4f3f667e6f833624a3)
-rw-r--r--video/out/gl_common.c7
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);