summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2020-03-21 18:31:06 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-07-07 22:19:09 +0200
commit0d00167b7e314cc40ee2a17b9146f6f0b83cd3be (patch)
treef37db18c36c40eeef7bb2dfd19635018f557c919
parent7556490b090b4bfb4f5c98c6a75a376c1c632dc6 (diff)
avformat/jvdec: Simplify cleanup after read_header failure
by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavformat/jvdec.c11
1 files 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,