diff mbox series

[FFmpeg-devel,17/54] avformat/jvdec: Simplify cleanup after read_header failure

Message ID HE1PR0301MB215444B7188A260C59B7CDFA8F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 0d00167b7e314cc40ee2a17b9146f6f0b83cd3be
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.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/jvdec.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
diff mbox series

Patch

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,