diff mbox series

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

Message ID HE1PR0301MB215452D10E8B2AF0FCBCAF3A8F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 2ca36ef08bf6a1bf8e9ceb26d55695e92b28cdaf
Headers show
Series [FFmpeg-devel,01/54] avformat: Add internal flags for AV(In|Out)putFormat
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt June 15, 2021, 11:32 p.m. UTC
by setting the FF_FMT_INIT_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@outlook.com>
---
 libavformat/concatdec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Nicolas George June 16, 2021, 9:15 a.m. UTC | #1
Andreas Rheinhardt (12021-06-16):
> by setting the FF_FMT_INIT_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@outlook.com>
> ---
>  libavformat/concatdec.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Looks ok. I am perfectly fine with clearing nb_files along with files to
make concat_read_close idempotent.

Thanks.

Regards,
diff mbox series

Patch

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 6d77398f48..96b4b96962 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;
 }
 
@@ -779,6 +776,7 @@  const AVInputFormat ff_concat_demuxer = {
     .name           = "concat",
     .long_name      = NULL_IF_CONFIG_SMALL("Virtual concatenation script"),
     .priv_data_size = sizeof(ConcatContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = concat_probe,
     .read_header    = concat_read_header,
     .read_packet    = concat_read_packet,