avformat: refactor avformat_close_input

Do not crash if the input format is not allocated yet.
pull/28/head
Luca Barbato 13 years ago
parent 4d1f443c3d
commit 44272c1ccc
  1. 17
      libavformat/utils.c

@ -2702,12 +2702,21 @@ void av_close_input_file(AVFormatContext *s)
void avformat_close_input(AVFormatContext **ps) void avformat_close_input(AVFormatContext **ps)
{ {
AVFormatContext *s = *ps; AVFormatContext *s = *ps;
AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ? AVIOContext *pb = s->pb;
NULL : s->pb;
if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) &&
(s->flags & AVFMT_FLAG_CUSTOM_IO))
pb = NULL;
flush_packet_queue(s); 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); avformat_free_context(s);
*ps = NULL; *ps = NULL;
avio_close(pb); avio_close(pb);

Loading…
Cancel
Save