mirror of https://github.com/mpv-player/mpv
af_lavfi: fix small memory leak
Plus restructure the error path to make this simpler.
This commit is contained in:
parent
41beaa653a
commit
c54673b86f
|
@ -92,6 +92,7 @@ static bool recreate_graph(struct af_instance *af, struct mp_audio *config)
|
||||||
void *tmp = talloc_new(NULL);
|
void *tmp = talloc_new(NULL);
|
||||||
struct priv *p = af->priv;
|
struct priv *p = af->priv;
|
||||||
AVFilterContext *in = NULL, *out = NULL;
|
AVFilterContext *in = NULL, *out = NULL;
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
if (!p->is_bridge && bstr0(p->cfg_graph).len == 0) {
|
if (!p->is_bridge && bstr0(p->cfg_graph).len == 0) {
|
||||||
MP_FATAL(af, "lavfi: no filter graph set\n");
|
MP_FATAL(af, "lavfi: no filter graph set\n");
|
||||||
|
@ -177,14 +178,17 @@ static bool recreate_graph(struct af_instance *af, struct mp_audio *config)
|
||||||
assert(out->nb_inputs == 1);
|
assert(out->nb_inputs == 1);
|
||||||
assert(in->nb_outputs == 1);
|
assert(in->nb_outputs == 1);
|
||||||
|
|
||||||
talloc_free(tmp);
|
ok = true;
|
||||||
return true;
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
MP_FATAL(af, "Can't configure libavfilter graph.\n");
|
|
||||||
avfilter_graph_free(&graph);
|
if (!ok) {
|
||||||
|
MP_FATAL(af, "Can't configure libavfilter graph.\n");
|
||||||
|
avfilter_graph_free(&graph);
|
||||||
|
}
|
||||||
|
avfilter_inout_free(&inputs);
|
||||||
|
avfilter_inout_free(&outputs);
|
||||||
talloc_free(tmp);
|
talloc_free(tmp);
|
||||||
return false;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reset(struct af_instance *af)
|
static void reset(struct af_instance *af)
|
||||||
|
|
Loading…
Reference in New Issue