lavd/opengl_enc: check strings before parsing them.
authorNicolas George <george@nsup.org>
Mon, 17 Feb 2020 11:59:27 +0000 (12:59 +0100)
committerNicolas George <george@nsup.org>
Thu, 20 Feb 2020 13:37:11 +0000 (14:37 +0100)
Fix a segfault if OpenGL was not initialized before calling
write_header().

libavdevice/opengl_enc.c

index fa94345..b07f9c2 100644 (file)
@@ -588,6 +588,10 @@ static av_cold int opengl_read_limits(AVFormatContext *h)
 
     version = glGetString(GL_VERSION);
     extensions = glGetString(GL_EXTENSIONS);
+    if (!version || !extensions) {
+        av_log(h, AV_LOG_ERROR, "No OpenGL context initialized for the current thread\n");
+        return AVERROR(ENOSYS);
+    }
 
     av_log(h, AV_LOG_DEBUG, "OpenGL version: %s\n", version);
     sscanf(version, "%d.%d", &major, &minor);