avfilter/vf_gblur: fix memory leaks if config_input() is called again

This commit is contained in:
Paul B Mahol 2022-02-10 09:06:22 +01:00
parent a0ede3cb56
commit f89cd457ca

View File

@ -249,11 +249,21 @@ void ff_gblur_init(GBlurContext *s)
ff_gblur_init_x86(s);
}
static av_cold void uninit(AVFilterContext *ctx)
{
GBlurContext *s = ctx->priv;
av_freep(&s->buffer);
av_freep(&s->localbuf);
}
static int config_input(AVFilterLink *inlink)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
GBlurContext *s = inlink->dst->priv;
uninit(inlink->dst);
s->depth = desc->comp[0].depth;
s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
@ -379,14 +389,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(outlink, out);
}
static av_cold void uninit(AVFilterContext *ctx)
{
GBlurContext *s = ctx->priv;
av_freep(&s->buffer);
av_freep(&s->localbuf);
}
static const AVFilterPad gblur_inputs[] = {
{
.name = "default",