From b0a60b7321c8878154f2488d99dd7b99cefca43b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 18 May 2013 12:23:02 +0200 Subject: 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. --- video/filter/vf.c | 3 +++ video/filter/vf_gradfun.c | 2 -- video/filter/vf_lavfi.c | 1 - video/filter/vf_scale.c | 1 - video/filter/vf_stereo3d.c | 6 ------ video/filter/vf_sub.c | 6 ------ 6 files changed, 3 insertions(+), 16 deletions(-) (limited to 'video') 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; -- cgit v1.2.3