summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-27 13:54:40 +0200
committerwm4 <wm4@nowhere>2017-10-27 13:54:40 +0200
commitc54673b86f7a6c923a2d625a31702cf053c5fa52 (patch)
treef1b1a66dffe55a67fe26a1cbb52d8be633ec49a6
parent41beaa653abee4839e5a60d9b7fb696d4a3f1446 (diff)
downloadmpv-c54673b86f7a6c923a2d625a31702cf053c5fa52.tar.bz2
mpv-c54673b86f7a6c923a2d625a31702cf053c5fa52.tar.xz
af_lavfi: fix small memory leak
Plus restructure the error path to make this simpler.
-rw-r--r--audio/filter/af_lavfi.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/audio/filter/af_lavfi.c b/audio/filter/af_lavfi.c
index 47edf20293..14bd1bb1f1 100644
--- a/audio/filter/af_lavfi.c
+++ b/audio/filter/af_lavfi.c
@@ -92,6 +92,7 @@ static bool recreate_graph(struct af_instance *af, struct mp_audio *config)
void *tmp = talloc_new(NULL);
struct priv *p = af->priv;
AVFilterContext *in = NULL, *out = NULL;
+ bool ok = false;
if (!p->is_bridge && bstr0(p->cfg_graph).len == 0) {
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(in->nb_outputs == 1);
- talloc_free(tmp);
- return true;
-
+ ok = true;
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);
- return false;
+ return ok;
}
static void reset(struct af_instance *af)