mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
avformat/tedcaptionsdec: Fix memleak upon read header failure
The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if allocating the AVStream for the subtitles fails. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 337783b118d4cc265759c103b672dd5d5d3e7cb8) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
b429a8e13f
commit
2dcc447410
@ -275,10 +275,13 @@ static int parse_file(AVIOContext *pb, FFDemuxSubtitlesQueue *subs)
|
|||||||
static av_cold int tedcaptions_read_header(AVFormatContext *avf)
|
static av_cold int tedcaptions_read_header(AVFormatContext *avf)
|
||||||
{
|
{
|
||||||
TEDCaptionsDemuxer *tc = avf->priv_data;
|
TEDCaptionsDemuxer *tc = avf->priv_data;
|
||||||
AVStream *st;
|
AVStream *st = avformat_new_stream(avf, NULL);
|
||||||
int ret, i;
|
int ret, i;
|
||||||
AVPacket *last;
|
AVPacket *last;
|
||||||
|
|
||||||
|
if (!st)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
ret = parse_file(avf->pb, &tc->subs);
|
ret = parse_file(avf->pb, &tc->subs);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (ret == AVERROR_INVALIDDATA)
|
if (ret == AVERROR_INVALIDDATA)
|
||||||
@ -292,9 +295,6 @@ static av_cold int tedcaptions_read_header(AVFormatContext *avf)
|
|||||||
tc->subs.subs[i].pts += tc->start_time;
|
tc->subs.subs[i].pts += tc->start_time;
|
||||||
|
|
||||||
last = &tc->subs.subs[tc->subs.nb_subs - 1];
|
last = &tc->subs.subs[tc->subs.nb_subs - 1];
|
||||||
st = avformat_new_stream(avf, NULL);
|
|
||||||
if (!st)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||||
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
|
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
|
||||||
avpriv_set_pts_info(st, 64, 1, 1000);
|
avpriv_set_pts_info(st, 64, 1, 1000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user