[FFmpeg-cvslog] avformat: refactor avformat_close_input

Luca Barbato git at videolan.org
Sat Sep 15 10:48:40 CEST 2012


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Tue Sep  4 16:05:28 2012 +0200| [44272c1cccfb92415801ae60693a7ed04e458916] | committer: Luca Barbato

avformat: refactor avformat_close_input

Do not crash if the input format is not allocated yet.

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

 libavformat/utils.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3a829a9..c0da7f2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2702,12 +2702,21 @@ void av_close_input_file(AVFormatContext *s)
 void avformat_close_input(AVFormatContext **ps)
 {
     AVFormatContext *s = *ps;
-    AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ?
-                       NULL : s->pb;
+    AVIOContext *pb = s->pb;
+
+    if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) &&
+        (s->flags & AVFMT_FLAG_CUSTOM_IO))
+        pb = NULL;
+
     flush_packet_queue(s);
-    if (s->iformat->read_close)
-        s->iformat->read_close(s);
+
+    if (s->iformat) {
+        if (s->iformat->read_close)
+            s->iformat->read_close(s);
+    }
+
     avformat_free_context(s);
+
     *ps = NULL;
 
     avio_close(pb);



More information about the ffmpeg-cvslog mailing list