scale: fix leak occurring when a scale filter is reconfigured
authorStefano Sabatini <stefano.sabatini-lala@poste.it>
Mon, 2 May 2011 10:35:39 +0000 (12:35 +0200)
committerStefano Sabatini <stefano.sabatini-lala@poste.it>
Mon, 2 May 2011 14:46:24 +0000 (16:46 +0200)
This currently only occurrs in vsrc_buffer in case of mid-stream
size/format change.

Fix trac issue #124.

libavfilter/vf_scale.c

index da84efc..9ff93bd 100644 (file)
@@ -214,14 +214,18 @@ static int config_props(AVFilterLink *outlink)
 
     scale->input_is_pal = av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL;
 
-    if(scale->sws)
+    if (scale->sws)
         sws_freeContext(scale->sws);
     scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format,
                                 outlink->w, outlink->h, outlink->format,
                                 scale->flags, NULL, NULL, NULL);
+    if (scale->isws[0])
+        sws_freeContext(scale->isws[0]);
     scale->isws[0] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format,
                                     outlink->w, outlink->h/2, outlink->format,
                                     scale->flags, NULL, NULL, NULL);
+    if (scale->isws[1])
+        sws_freeContext(scale->isws[1]);
     scale->isws[1] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format,
                                     outlink->w, outlink->h/2, outlink->format,
                                     scale->flags, NULL, NULL, NULL);