[FFmpeg-cvslog] avopt: Check whether the object actually has got an AVClass

Martin Storsjö git at videolan.org
Thu Aug 1 12:43:41 CEST 2013


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Mon Jul 29 14:53:01 2013 +0300| [c7e921a54ffe7feb9f695c82f0a0764ab8d0f62b] | committer: Martin Storsjö

avopt: Check whether the object actually has got an AVClass

AVIOContext has got an av_class member that only gets set if
opening the context using avio_open2, but not if allocating a
custom IO context. A caller that wants to read AVOptions from
an AVIOContext (recursively using AV_OPT_SEARCH_CHILDREN) may
not know if the AVIOContext actually has got a class set or not.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c7e921a54ffe7feb9f695c82f0a0764ab8d0f62b
---

 libavutil/opt.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index f2b9473..cba5b29 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -650,6 +650,9 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
     const AVClass  *c = *(AVClass**)obj;
     const AVOption *o = NULL;
 
+    if (!c)
+        return NULL;
+
     if (search_flags & AV_OPT_SEARCH_CHILDREN) {
         if (search_flags & AV_OPT_SEARCH_FAKE_OBJ) {
             const AVClass *child = NULL;



More information about the ffmpeg-cvslog mailing list