[FFmpeg-devel] [PATCH 11/21] avformat/jvdec: Simplify cleanup after read_header failure

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sun Mar 22 05:47:46 EET 2020


by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag.

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

diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index 551f8069e6..efa034c9ce 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -114,7 +114,6 @@ static int read_header(AVFormatContext *s)
 
     jv->frames = av_malloc(ast->nb_index_entries * sizeof(JVFrame));
     if (!jv->frames) {
-        av_freep(&ast->index_entries);
         return AVERROR(ENOMEM);
     }
     offset = 0x68 + ast->nb_index_entries * 16;
@@ -137,9 +136,6 @@ static int read_header(AVFormatContext *s)
                     - jvf->video_size
                     - jvf->palette_size < 0) {
             if (s->error_recognition & AV_EF_EXPLODE) {
-                read_close(s);
-                av_freep(&jv->frames);
-                av_freep(&ast->index_entries);
                 return AVERROR_INVALIDDATA;
             }
             jvf->audio_size   =
@@ -263,4 +259,5 @@ AVInputFormat ff_jv_demuxer = {
     .read_packet    = read_packet,
     .read_seek      = read_seek,
     .read_close     = read_close,
+    .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP,
 };
-- 
2.20.1



More information about the ffmpeg-devel mailing list