[FFmpeg-devel] [PATCH 2/4] avutil/opt: check offset / constness correctness

Michael Niedermayer michaelni at gmx.at
Sat Apr 13 20:37:13 CEST 2013


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavutil/opt.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index b4d1d67..23f57b5 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -66,7 +66,7 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
     AVClass *class = *(AVClass**)obj;
 #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
     AVOption *o = last && last[1].name ? last + 1 : class->option;
-    if(o) {
+    if(o && (o->name || o->help || o->offset || o->min || o->max || o->unit || o->default_val.i64)) {
         int faulty = 0;
         if (o->type == AV_OPT_TYPE_DOUBLE || o->type == AV_OPT_TYPE_FLOAT) {
             faulty |= (o->min > o->default_val.dbl || o->default_val.dbl > o->max);
@@ -80,6 +80,11 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
             av_log(obj, AV_LOG_FATAL, "Invalid min/default/max combination in %s\n", o->name);
             av_assert2(0);
         }
+        if (   (o->offset && o->type == AV_OPT_TYPE_CONST && o->offset != last->offset)
+            || o->offset < 0 ) {
+            av_log(obj, AV_LOG_FATAL, "Invalid offset / type combination in %s\n", o->name);
+            av_assert2(0);
+        }
     }
 #endif
     if (!last && class->option && class->option[0].name)
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list