summaryrefslogtreecommitdiff
path: root/libavformat/mpeg.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2020-03-21 21:03:44 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-07-08 11:46:40 +0200
commitbcdc1d106062677c17e721875b77f8dcae3b2a1a (patch)
tree9595c3c0e323e1ecbf326c41c313dbeb50f0fb6f /libavformat/mpeg.c
parentc6e9672b50f4d341f94d3fd2ec3c2fc180dacc66 (diff)
avformat/mpeg: Simplify cleanup after reading vobsub header fails
by setting the FF_FMT_INIT_CLEANUP flag. Furthermore, also remove an unnecessary check for NULL before avformat_close_input(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/mpeg.c')
-rw-r--r--libavformat/mpeg.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 178e71d891..4b7493395d 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -723,8 +723,7 @@ static int vobsub_read_close(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++)
ff_subtitles_queue_clean(&vobsub->q[i]);
- if (vobsub->sub_ctx)
- avformat_close_input(&vobsub->sub_ctx);
+ avformat_close_input(&vobsub->sub_ctx);
return 0;
}
@@ -768,17 +767,17 @@ static int vobsub_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
}
- av_bprint_init(&header, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
-
if ((ret = ff_copy_whiteblacklists(vobsub->sub_ctx, s)) < 0)
- goto end;
+ return ret;
ret = avformat_open_input(&vobsub->sub_ctx, vobsub->sub_name, iformat, NULL);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Unable to open %s as MPEG subtitles\n", vobsub->sub_name);
- goto end;
+ return ret;
}
+ av_bprint_init(&header, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
+
while (!avio_feof(s->pb)) {
char line[MAX_LINE_SIZE];
int len = ff_get_line(s->pb, line, sizeof(line));
@@ -911,8 +910,6 @@ static int vobsub_read_header(AVFormatContext *s)
memcpy(par->extradata, header.str, header.len);
}
end:
- if (ret < 0)
- vobsub_read_close(s);
av_bprint_finalize(&header, NULL);
return ret;
}
@@ -1044,6 +1041,7 @@ const AVInputFormat ff_vobsub_demuxer = {
.name = "vobsub",
.long_name = NULL_IF_CONFIG_SMALL("VobSub subtitle format"),
.priv_data_size = sizeof(VobSubDemuxContext),
+ .flags_internal = FF_FMT_INIT_CLEANUP,
.read_probe = vobsub_probe,
.read_header = vobsub_read_header,
.read_packet = vobsub_read_packet,