[vlc-commits] cvpx: fix error case in Open

Alexandre Janniaux git at videolan.org
Tue Aug 18 15:09:24 CEST 2020


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Tue Jul 28 13:54:02 2020 +0200| [488234788afe750d42aa61ef6eff7b568915d257] | committer: Alexandre Janniaux

cvpx: fix error case in Open

As the code was returning `ret` but didn't set it before jumping to the
error: label. In case of error, p_sys wasn't NULL too, which could lead
to failure in other filters.

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

 modules/video_chroma/cvpx.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/modules/video_chroma/cvpx.c b/modules/video_chroma/cvpx.c
index 00736d8ea0..3e73e5bc44 100644
--- a/modules/video_chroma/cvpx.c
+++ b/modules/video_chroma/cvpx.c
@@ -334,6 +334,7 @@ static int Open(vlc_object_t *obj)
         if (dec_dev == NULL)
         {
             msg_Err(p_filter, "Missing decoder device");
+            ret = VLC_EGENERIC;
             goto error;
         }
         const static struct vlc_video_context_operations vt_vctx_ops = {
@@ -344,24 +345,35 @@ static int Open(vlc_object_t *obj)
                                          0, &vt_vctx_ops);
         vlc_decoder_device_Release(dec_dev);
         if (!p_filter->vctx_out)
+        {
+            ret = VLC_ENOMEM;
             goto error;
+        }
 
         p_sys->pool = cvpxpool_create(&p_filter->fmt_out.video, 3);
         if (p_sys->pool == NULL)
+        {
+            ret = VLC_ENOMEM;
             goto error;
+        }
     }
     else
     {
         if (p_filter->vctx_in == NULL ||
             vlc_video_context_GetType(p_filter->vctx_in) != VLC_VIDEO_CONTEXT_CVPX)
-            return VLC_EGENERIC;
+        ret = VLC_EGENERIC;
+        goto error;
     }
 
     p_filter->fmt_out.i_codec = p_filter->fmt_out.video.i_chroma;
     return VLC_SUCCESS;
 error:
     Close(obj);
+    p_filter->p_sys = NULL;
+
+    assert(ret != VLC_SUCCESS);
     return ret;
+
 #undef CASE_CVPX_INPUT
 #undef CASE_CVPX_OUTPUT
 }



More information about the vlc-commits mailing list