summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-18 12:23:02 +0200
committerwm4 <wm4@nowhere>2013-05-18 17:45:55 +0200
commitb0a60b7321c8878154f2488d99dd7b99cefca43b (patch)
tree8c2e881ab62d43b263fe58ca4dc0ef3cf42d3496 /video
parentf569d245ba37898a79e853cb6fbd906dd992b531 (diff)
downloadmpv-b0a60b7321c8878154f2488d99dd7b99cefca43b.tar.bz2
mpv-b0a60b7321c8878154f2488d99dd7b99cefca43b.tar.xz
video/filter: fix option parser memory leak
This happens only if an option actually allocates memory (like strings). Change filter API such that vf->priv is free'd by vf.c instead by the filters. vf.c will free the option values as well.
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf.c3
-rw-r--r--video/filter/vf_gradfun.c2
-rw-r--r--video/filter/vf_lavfi.c1
-rw-r--r--video/filter/vf_scale.c1
-rw-r--r--video/filter/vf_stereo3d.c6
-rw-r--r--video/filter/vf_sub.c6
6 files changed, 3 insertions, 16 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 257d65e58b..215bf0dc0e 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -501,6 +501,9 @@ void vf_uninit_filter(vf_instance_t *vf)
if (vf->uninit)
vf->uninit(vf);
vf_forget_frames(vf);
+ const m_struct_t *st = vf->info->opts;
+ if (st)
+ m_struct_free(st, vf->priv);
talloc_free(vf);
}
diff --git a/video/filter/vf_gradfun.c b/video/filter/vf_gradfun.c
index ce4e5c9f56..227e16b028 100644
--- a/video/filter/vf_gradfun.c
+++ b/video/filter/vf_gradfun.c
@@ -352,8 +352,6 @@ static void uninit(struct vf_instance *vf)
{
if (!vf->priv) return;
av_free(vf->priv->buf);
- free(vf->priv);
- vf->priv = NULL;
}
static int vf_open(vf_instance_t *vf, char *args)
diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c
index 0b01e9b425..f581fe950e 100644
--- a/video/filter/vf_lavfi.c
+++ b/video/filter/vf_lavfi.c
@@ -310,7 +310,6 @@ static void uninit(struct vf_instance *vf)
if (!vf->priv)
return;
destroy_graph(vf);
- free(vf->priv);
}
static int vf_open(vf_instance_t *vf, char *args)
diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c
index 92b9e71d08..f357581bb3 100644
--- a/video/filter/vf_scale.c
+++ b/video/filter/vf_scale.c
@@ -506,7 +506,6 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){
static void uninit(struct vf_instance *vf){
if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
- free(vf->priv);
}
static int vf_open(vf_instance_t *vf, char *args){
diff --git a/video/filter/vf_stereo3d.c b/video/filter/vf_stereo3d.c
index 956d6302d0..555e87f78e 100644
--- a/video/filter/vf_stereo3d.c
+++ b/video/filter/vf_stereo3d.c
@@ -394,15 +394,9 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
return 0;
}
-static void uninit(vf_instance_t *vf)
-{
- free(vf->priv);
-}
-
static int vf_open(vf_instance_t *vf, char *args)
{
vf->config = config;
- vf->uninit = uninit;
vf->filter = filter;
vf->query_format = query_format;
diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c
index ae1390b6e9..e918574c30 100644
--- a/video/filter/vf_sub.c
+++ b/video/filter/vf_sub.c
@@ -141,16 +141,10 @@ static int control(vf_instance_t *vf, int request, void *data)
return vf_next_control(vf, request, data);
}
-static void uninit(struct vf_instance *vf)
-{
- free(vf->priv);
-}
-
static int vf_open(vf_instance_t *vf, char *args)
{
vf->config = config;
vf->query_format = query_format;
- vf->uninit = uninit;
vf->control = control;
vf->filter = filter;
return 1;