mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-12 10:15:22 +00:00
avfilter/vf_subtitles: Fix leaks on failure
init_subtitles() sometimes returned directly upon error without cleaning
up after itself. The easiest way to trigger this is by using
picture-based subtitles; it is also possible to run into this in case of
missing decoders or allocation failures.
Furthermore, return the proper error code in case of missing decoder.
Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit 77ace1ffea
)
This commit is contained in:
parent
d0a8273efe
commit
a080af9b8c
@ -384,13 +384,15 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
|
|||||||
if (!dec) {
|
if (!dec) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to find subtitle codec %s\n",
|
av_log(ctx, AV_LOG_ERROR, "Failed to find subtitle codec %s\n",
|
||||||
avcodec_get_name(st->codecpar->codec_id));
|
avcodec_get_name(st->codecpar->codec_id));
|
||||||
return AVERROR(EINVAL);
|
ret = AVERROR_DECODER_NOT_FOUND;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
dec_desc = avcodec_descriptor_get(st->codecpar->codec_id);
|
dec_desc = avcodec_descriptor_get(st->codecpar->codec_id);
|
||||||
if (dec_desc && !(dec_desc->props & AV_CODEC_PROP_TEXT_SUB)) {
|
if (dec_desc && !(dec_desc->props & AV_CODEC_PROP_TEXT_SUB)) {
|
||||||
av_log(ctx, AV_LOG_ERROR,
|
av_log(ctx, AV_LOG_ERROR,
|
||||||
"Only text based subtitles are currently supported\n");
|
"Only text based subtitles are currently supported\n");
|
||||||
return AVERROR_PATCHWELCOME;
|
ret = AVERROR_PATCHWELCOME;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
if (ass->charenc)
|
if (ass->charenc)
|
||||||
av_dict_set(&codec_opts, "sub_charenc", ass->charenc, 0);
|
av_dict_set(&codec_opts, "sub_charenc", ass->charenc, 0);
|
||||||
@ -398,8 +400,10 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
|
|||||||
av_dict_set(&codec_opts, "sub_text_format", "ass", 0);
|
av_dict_set(&codec_opts, "sub_text_format", "ass", 0);
|
||||||
|
|
||||||
dec_ctx = avcodec_alloc_context3(dec);
|
dec_ctx = avcodec_alloc_context3(dec);
|
||||||
if (!dec_ctx)
|
if (!dec_ctx) {
|
||||||
return AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
ret = avcodec_parameters_to_context(dec_ctx, st->codecpar);
|
ret = avcodec_parameters_to_context(dec_ctx, st->codecpar);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user