avfilter/vf_copy: check for error cases and handle them

This commit is contained in:
Paul B Mahol 2019-10-01 13:45:29 +02:00
parent c9473229c9
commit a9500441a7
1 changed files with 14 additions and 6 deletions

View File

@ -48,15 +48,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFrame *out = ff_get_video_buffer(outlink, in->width, in->height);
int ret;
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, in);
av_frame_copy(out, in);
if (!out)
ret = AVERROR(ENOMEM);
ret = av_frame_copy_props(out, in);
if (ret < 0)
goto fail;
ret = av_frame_copy(out, in);
if (ret < 0)
goto fail;
av_frame_free(&in);
return ff_filter_frame(outlink, out);
fail:
av_frame_free(&in);
av_frame_free(&out);
return ret;
}
static const AVFilterPad avfilter_vf_copy_inputs[] = {