[FFmpeg-cvslog] opt: do not crash in av_set_options_string() if opts == NULL

Stefano Sabatini git at videolan.org
Sun Jun 19 20:21:20 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Sun Jun 19 02:49:04 2011 +0200| [141f03541b39e131a5e8aa776a88abe77b70618e] | committer: Stefano Sabatini

opt: do not crash in av_set_options_string() if opts == NULL

Add missing NULL check, and update documentation accordingly.

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

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

diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 36dcf8f..4d6ef66 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -41,7 +41,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR 51
 #define LIBAVUTIL_VERSION_MINOR  9
-#define LIBAVUTIL_VERSION_MICRO  0
+#define LIBAVUTIL_VERSION_MICRO  1
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 8c35148..c0b529b 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -521,6 +521,8 @@ int av_set_options_string(void *ctx, const char *opts,
 {
     int ret, count = 0;
 
+    if (!opts)
+        return 0;
     while (*opts) {
         if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0)
             return ret;
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 97a1cb5..68873de 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -169,6 +169,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags);
  * key. ctx must be an AVClass context, storing is done using
  * AVOptions.
  *
+ * @param opts options string to parse, may be NULL
  * @param key_val_sep a 0-terminated list of characters used to
  * separate key from value
  * @param pairs_sep a 0-terminated list of characters used to separate



More information about the ffmpeg-cvslog mailing list