diff mbox series

[FFmpeg-devel,9/9] avformat/concatdec: Simplify cleanup after read_header failure

Message ID 20200721021215.32647-7-andreas.rheinhardt@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v2,1/2] avformat: Redo cleanup of demuxer upon read_header() failure | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt July 21, 2020, 2:12 a.m. UTC
by setting the AVFMT_HEADER_CLEANUP flag.

(Btw: concat_read_close() is not idempotent (it frees cat->files, but
doesn't reset cat->nb_files), so this demuxer was incompatible with
simply calling read_close generically upon read_header failure.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/concatdec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Nicolas George July 21, 2020, 3:24 p.m. UTC | #1
Andreas Rheinhardt (12020-07-21):
> by setting the AVFMT_HEADER_CLEANUP flag.
> 
> (Btw: concat_read_close() is not idempotent (it frees cat->files, but
> doesn't reset cat->nb_files), so this demuxer was incompatible with
> simply calling read_close generically upon read_header failure.)

If you think it would useful or more elegant to reset nb_files when
freeing files, then by all means go ahead. I agree on the elegance part
at least, but I do not have the time right now.

The patch looks ok anyway, thanks.

Regards,
diff mbox series

Patch

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 4b56b61404..5f3c63a621 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -510,12 +510,9 @@  static int concat_read_header(AVFormatContext *avf)
                                                MATCH_ONE_TO_ONE;
     if ((ret = open_file(avf, 0)) < 0)
         goto fail;
-    av_bprint_finalize(&bp, NULL);
-    return 0;
 
 fail:
     av_bprint_finalize(&bp, NULL);
-    concat_read_close(avf);
     return ret;
 }
 
@@ -778,6 +775,7 @@  static const AVClass concat_class = {
 AVInputFormat ff_concat_demuxer = {
     .name           = "concat",
     .long_name      = NULL_IF_CONFIG_SMALL("Virtual concatenation script"),
+    .flags          = AVFMT_HEADER_CLEANUP,
     .priv_data_size = sizeof(ConcatContext),
     .read_probe     = concat_probe,
     .read_header    = concat_read_header,