[vlc-commits] chroma: cvpx: rework error handling in Open

Thomas Guillem git at videolan.org
Fri Jan 10 13:02:04 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jan  9 15:05:40 2020 +0100| [b81811fcb3f8dffa6394a04d2fa7ea83fc7f2395] | committer: Thomas Guillem

chroma: cvpx: rework error handling in Open

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

 modules/video_chroma/cvpx.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/modules/video_chroma/cvpx.c b/modules/video_chroma/cvpx.c
index a1e6e2c897..6522ca710a 100644
--- a/modules/video_chroma/cvpx.c
+++ b/modules/video_chroma/cvpx.c
@@ -310,20 +310,21 @@ static int Open(vlc_object_t *obj)
     p_sys->sw.fmt = sw_fmt;
 
     unsigned i_cache_width = p_filter->fmt_in.video.i_width * i_cache_pixel_bytes;
-    if (CopyInitCache(&p_sys->sw.cache, i_cache_width) != VLC_SUCCESS)
-    {
-        free(p_sys);
-        return VLC_ENOMEM;
-    }
+    int ret = CopyInitCache(&p_sys->sw.cache, i_cache_width);
+    if (ret != VLC_SUCCESS)
+        goto error;
 
-    if (b_need_pool
-     && (p_sys->pool = cvpxpool_create(&p_filter->fmt_out.video, 3)) == NULL)
+    if (b_need_pool)
     {
-        Close(obj);
-        return VLC_EGENERIC;
+        p_sys->pool = cvpxpool_create(&p_filter->fmt_out.video, 3);
+        if (p_sys->pool == NULL)
+            goto error;
     }
 
     return VLC_SUCCESS;
+error:
+    Close(obj);
+    return ret;
 #undef CASE_CVPX_INPUT
 #undef CASE_CVPX_OUTPUT
 }



More information about the vlc-commits mailing list