[vlc-commits] ci_filters: fix leak on error path

Thomas Guillem git at videolan.org
Tue Sep 12 16:48:51 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep 12 13:02:51 2017 +0200| [261e710b11430872960f5e0fc5bacfb9eb4c9178] | committer: Thomas Guillem

ci_filters: fix leak on error path

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=261e710b11430872960f5e0fc5bacfb9eb4c9178
---

 modules/video_filter/ci_filters.m | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/modules/video_filter/ci_filters.m b/modules/video_filter/ci_filters.m
index f058b98b3e..16a6f8d219 100644
--- a/modules/video_filter/ci_filters.m
+++ b/modules/video_filter/ci_filters.m
@@ -432,6 +432,23 @@ CVPX_buffer_new(filter_t *converter)
     return pic;
 }
 
+static void
+Close_RemoveConverters(filter_t *filter, struct ci_filters_ctx *ctx)
+{
+    VLC_UNUSED(filter);
+    if (ctx->dst_converter)
+    {
+        module_unneed(ctx->dst_converter, ctx->dst_converter->p_module);
+        vlc_object_release(ctx->dst_converter);
+        CVPixelBufferPoolRelease(ctx->outconv_cvpx_pool);
+    }
+    if (ctx->src_converter)
+    {
+        module_unneed(ctx->src_converter, ctx->src_converter->p_module);
+        vlc_object_release(ctx->src_converter);
+    }
+}
+
 static int
 Open_AddConverters(filter_t *filter, struct ci_filters_ctx *ctx)
 {
@@ -573,6 +590,7 @@ error:
     {
         if (ctx->color_space)
             CGColorSpaceRelease(ctx->color_space);
+        Close_RemoveConverters(filter, ctx);
         if (ctx->cvpx_pool)
             CVPixelBufferPoolRelease(ctx->cvpx_pool);
         free(ctx);
@@ -626,20 +644,11 @@ Close(vlc_object_t *obj)
 
     if (!ctx->fchain)
     {
-        if (ctx->dst_converter)
-        {
-            module_unneed(ctx->dst_converter, ctx->dst_converter->p_module);
-            vlc_object_release(ctx->dst_converter);
-            CVPixelBufferPoolRelease(ctx->outconv_cvpx_pool);
-        }
-        if (ctx->src_converter)
-        {
-            module_unneed(ctx->src_converter, ctx->src_converter->p_module);
-            vlc_object_release(ctx->src_converter);
-        }
+        Close_RemoveConverters(filter, ctx);
+        if (ctx->cvpx_pool)
+            CVPixelBufferPoolRelease(ctx->cvpx_pool);
         if (ctx->color_space)
             CGColorSpaceRelease(ctx->color_space);
-        CVPixelBufferPoolRelease(ctx->cvpx_pool);
         free(ctx);
         var_Destroy(filter->obj.parent, "ci-filters-ctx");
     }



More information about the vlc-commits mailing list