cmdutils: fix crash if no name for "ffmpeg -h protocol"
authorJun Zhao <barryjzhao@tencent.com>
Thu, 30 Jan 2020 14:03:17 +0000 (22:03 +0800)
committerJames Almer <jamrial@gmail.com>
Thu, 30 Jan 2020 15:50:22 +0000 (12:50 -0300)
fix crash when used the command like:
- ffmpeg -h protocol
- ffmpeg -h protocol=

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
fftools/cmdutils.c

index 2284631..f0f2b4f 100644 (file)
@@ -1872,8 +1872,14 @@ static void show_help_demuxer(const char *name)
 
 static void show_help_protocol(const char *name)
 {
-    const AVClass *proto_class = avio_protocol_get_class(name);
+    const AVClass *proto_class;
 
+    if (!name) {
+        av_log(NULL, AV_LOG_ERROR, "No protocol name specified.\n");
+        return;
+    }
+
+    proto_class = avio_protocol_get_class(name);
     if (!proto_class) {
         av_log(NULL, AV_LOG_ERROR, "Unknown protocol '%s'.\n", name);
         return;