[FFmpeg-cvslog] avformat: make avformat_close_input() more tolerant.

Clément Bœsch git at videolan.org
Wed Sep 4 22:14:26 CEST 2013


ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Tue Sep  3 22:22:19 2013 +0200| [36cd017acd9cac0e6695124c052a59fb1fc13145] | committer: Clément Bœsch

avformat: make avformat_close_input() more tolerant.

The purpose of this commit is to make error management simpler and less
error prone, just like av_free() which is safe with NULL.

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

 doc/APIchanges        |    3 +++
 libavformat/utils.c   |   10 ++++++++--
 libavformat/version.h |    2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c4255bc..12b9af4 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2012-10-22
 
 API changes, most recent first:
 
+2013-xx-xx - xxxxxxx - lavf 55.16.101 - avformat.h
+  avformat_close_input() argument can be NULL and point on NULL.
+
 2013-08-29 - e31db62 - lavf 55.15.100 - avformat.h
   Add av_format_get_probe_score().
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 763588b..b12d5b8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3252,8 +3252,14 @@ void av_close_input_file(AVFormatContext *s)
 
 void avformat_close_input(AVFormatContext **ps)
 {
-    AVFormatContext *s = *ps;
-    AVIOContext *pb = s->pb;
+    AVFormatContext *s;
+    AVIOContext *pb;
+
+    if (!ps || !*ps)
+        return;
+
+    s = *ps;
+    pb = s->pb;
 
     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
         (s->flags & AVFMT_FLAG_CUSTOM_IO))
diff --git a/libavformat/version.h b/libavformat/version.h
index 47a022b..8ae40ab 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 55
 #define LIBAVFORMAT_VERSION_MINOR 16
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list