opt: avoid segfault in av_opt_next() if the class does not have an option list
authorJustin Ruggles <justin.ruggles@gmail.com>
Thu, 8 Nov 2012 23:35:49 +0000 (18:35 -0500)
committerJustin Ruggles <justin.ruggles@gmail.com>
Sat, 22 Dec 2012 20:43:27 +0000 (15:43 -0500)
CC: libav-stable@libav.org
libavutil/opt.c

index e199170075d46f0a5a9a615341a0530937ca259f..8a98a9ef55be2638e8e1e0d8dba7eb4837a5c3b5 100644 (file)
 const AVOption *av_opt_next(void *obj, const AVOption *last)
 {
     AVClass *class = *(AVClass**)obj;
-    if (!last && class->option[0].name) return class->option;
-    if (last && last[1].name)           return ++last;
+    if (!last && class->option && class->option[0].name)
+        return class->option;
+    if (last && last[1].name)
+        return ++last;
     return NULL;
 }