1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avformat/microdvddec: Simplify cleanup after read_header failure

by setting the FF_FMT_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2020-03-21 18:31:06 +01:00
parent d18eee412a
commit da45c89fe1

View File

@ -121,7 +121,7 @@ static int microdvd_read_header(AVFormatContext *s)
int size = strlen(line + 11); int size = strlen(line + 11);
ret = ff_alloc_extradata(st->codecpar, size); ret = ff_alloc_extradata(st->codecpar, size);
if (ret < 0) if (ret < 0)
goto fail; return ret;
memcpy(st->codecpar->extradata, line + 11, size); memcpy(st->codecpar->extradata, line + 11, size);
continue; continue;
} }
@ -142,10 +142,8 @@ static int microdvd_read_header(AVFormatContext *s)
if (pts == AV_NOPTS_VALUE) if (pts == AV_NOPTS_VALUE)
continue; continue;
sub = ff_subtitles_queue_insert(&microdvd->q, p, strlen(p), 0); sub = ff_subtitles_queue_insert(&microdvd->q, p, strlen(p), 0);
if (!sub) { if (!sub)
ret = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto fail;
}
sub->pos = pos; sub->pos = pos;
sub->pts = pts; sub->pts = pts;
sub->duration = get_duration(line); sub->duration = get_duration(line);
@ -162,9 +160,6 @@ static int microdvd_read_header(AVFormatContext *s)
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_id = AV_CODEC_ID_MICRODVD; st->codecpar->codec_id = AV_CODEC_ID_MICRODVD;
return 0; return 0;
fail:
ff_subtitles_queue_clean(&microdvd->q);
return ret;
} }
static int microdvd_read_packet(AVFormatContext *s, AVPacket *pkt) static int microdvd_read_packet(AVFormatContext *s, AVPacket *pkt)
@ -207,6 +202,7 @@ const AVInputFormat ff_microdvd_demuxer = {
.name = "microdvd", .name = "microdvd",
.long_name = NULL_IF_CONFIG_SMALL("MicroDVD subtitle format"), .long_name = NULL_IF_CONFIG_SMALL("MicroDVD subtitle format"),
.priv_data_size = sizeof(MicroDVDContext), .priv_data_size = sizeof(MicroDVDContext),
.flags_internal = FF_FMT_INIT_CLEANUP,
.read_probe = microdvd_probe, .read_probe = microdvd_probe,
.read_header = microdvd_read_header, .read_header = microdvd_read_header,
.read_packet = microdvd_read_packet, .read_packet = microdvd_read_packet,