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>
pull/359/head
Andreas Rheinhardt 5 years ago
parent 7556490b09
commit 0d00167b7e
  1. 11
      libavformat/jvdec.c

@ -113,10 +113,8 @@ static int read_header(AVFormatContext *s)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
jv->frames = av_malloc(ast->internal->nb_index_entries * sizeof(JVFrame)); jv->frames = av_malloc(ast->internal->nb_index_entries * sizeof(JVFrame));
if (!jv->frames) { if (!jv->frames)
av_freep(&ast->internal->index_entries);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
offset = 0x68 + ast->internal->nb_index_entries * 16; offset = 0x68 + ast->internal->nb_index_entries * 16;
for (i = 0; i < ast->internal->nb_index_entries; i++) { for (i = 0; i < ast->internal->nb_index_entries; i++) {
AVIndexEntry *e = ast->internal->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 e->size - jvf->audio_size
- jvf->video_size - jvf->video_size
- jvf->palette_size < 0) { - jvf->palette_size < 0) {
if (s->error_recognition & AV_EF_EXPLODE) { if (s->error_recognition & AV_EF_EXPLODE)
read_close(s);
av_freep(&jv->frames);
av_freep(&ast->internal->index_entries);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
}
jvf->audio_size = jvf->audio_size =
jvf->video_size = jvf->video_size =
jvf->palette_size = 0; jvf->palette_size = 0;
@ -258,6 +252,7 @@ const AVInputFormat ff_jv_demuxer = {
.name = "jv", .name = "jv",
.long_name = NULL_IF_CONFIG_SMALL("Bitmap Brothers JV"), .long_name = NULL_IF_CONFIG_SMALL("Bitmap Brothers JV"),
.priv_data_size = sizeof(JVDemuxContext), .priv_data_size = sizeof(JVDemuxContext),
.flags_internal = FF_FMT_INIT_CLEANUP,
.read_probe = read_probe, .read_probe = read_probe,
.read_header = read_header, .read_header = read_header,
.read_packet = read_packet, .read_packet = read_packet,

Loading…
Cancel
Save