[FFmpeg-cvslog] avformat/jvdec: Simplify cleanup after read_header failure

Andreas Rheinhardt git at videolan.org
Thu Jul 8 16:44:28 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Mar 21 18:31:06 2020 +0100| [0d00167b7e314cc40ee2a17b9146f6f0b83cd3be] | committer: Andreas Rheinhardt

avformat/jvdec: Simplify cleanup after read_header failure

by setting the FF_FMT_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavformat/jvdec.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index 948cab37e5..a044f50831 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -113,10 +113,8 @@ static int read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     jv->frames = av_malloc(ast->internal->nb_index_entries * sizeof(JVFrame));
-    if (!jv->frames) {
-        av_freep(&ast->internal->index_entries);
+    if (!jv->frames)
         return AVERROR(ENOMEM);
-    }
     offset = 0x68 + ast->internal->nb_index_entries * 16;
     for (i = 0; i < ast->internal->nb_index_entries; i++) {
         AVIndexEntry *e   = ast->internal->index_entries + i;
@@ -136,12 +134,8 @@ static int read_header(AVFormatContext *s)
             e->size - jvf->audio_size
                     - jvf->video_size
                     - jvf->palette_size < 0) {
-            if (s->error_recognition & AV_EF_EXPLODE) {
-                read_close(s);
-                av_freep(&jv->frames);
-                av_freep(&ast->internal->index_entries);
+            if (s->error_recognition & AV_EF_EXPLODE)
                 return AVERROR_INVALIDDATA;
-            }
             jvf->audio_size   =
             jvf->video_size   =
             jvf->palette_size = 0;
@@ -258,6 +252,7 @@ const AVInputFormat ff_jv_demuxer = {
     .name           = "jv",
     .long_name      = NULL_IF_CONFIG_SMALL("Bitmap Brothers JV"),
     .priv_data_size = sizeof(JVDemuxContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = read_probe,
     .read_header    = read_header,
     .read_packet    = read_packet,



More information about the ffmpeg-cvslog mailing list