From 9861abf8ffa4c9e7c4ad9a4f3f667e6f833624a3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 20 Feb 2015 18:53:35 +0100 Subject: 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". --- video/out/gl_common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'video/out') 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); -- cgit v1.2.3