[libav-commits] opt: avoid segfault in av_opt_next() if the class does not have an option list

Justin Ruggles git at libav.org
Sat Jan 12 18:38:54 CET 2013


Module: libav
Branch: release/0.8
Commit: dfb7a638e6b9d4b86b7e3c5cf97bdd7621adc5f6

Author:    Justin Ruggles <justin.ruggles at gmail.com>
Committer: Reinhard Tartler <siretart at tauware.de>
Date:      Thu Nov  8 18:35:49 2012 -0500

opt: avoid segfault in av_opt_next() if the class does not have an option list

CC: libav-stable at libav.org
(cherry picked from commit d02202e08a994c6c80f0256ae756698541b59902)

Signed-off-by: Reinhard Tartler <siretart at tauware.de>

---

 libavutil/opt.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 7c53024..aea381e 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -57,8 +57,10 @@ const AVOption *av_next_option(void *obj, const AVOption *last)
 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;
 }
 



More information about the libav-commits mailing list