[FFmpeg-cvslog] vsrc_buffer: Store allocated scale filter and free it later.

Michael Niedermayer git at videolan.org
Sat Mar 31 10:30:07 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Mar 31 08:49:18 2012 +0200| [2d54bbb9502442b84e19c5f424a566a35cf852c6] | committer: Michael Niedermayer

vsrc_buffer: Store allocated scale filter and free it later.

Fixes a memleak.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d54bbb9502442b84e19c5f424a566a35cf852c6
---

 libavfilter/vsrc_buffer.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 743698e..dbccbe0 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -32,6 +32,7 @@
 
 typedef struct {
     AVFilterBufferRef *picref;
+    AVFilterContext   *scale;
     int               h, w;
     enum PixelFormat  pix_fmt;
     AVRational        time_base;     ///< time_base to set in the output link
@@ -81,14 +82,14 @@ int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter,
             if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
                 return ret;
 
+            c->scale = scale;
+
             snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
             if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
-                avfilter_free(scale);
                 return ret;
             }
 
             if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
-                avfilter_free(scale);
                 return ret;
             }
             scale->outputs[0]->time_base = scale->inputs[0]->time_base;
@@ -188,6 +189,8 @@ static av_cold void uninit(AVFilterContext *ctx)
     if (s->picref)
         avfilter_unref_buffer(s->picref);
     s->picref = NULL;
+    avfilter_free(s->scale);
+    s->scale = NULL;
 }
 
 static int query_formats(AVFilterContext *ctx)



More information about the ffmpeg-cvslog mailing list