vlc/vlc-3.0 | branch: master | Steve Lhomme <rob...@ycbcr.xyz> | Sat Feb 10 
09:10:42 2018 +0100| [4bbc366b9b887997f7bd694873463e48bd822053] | committer: 
Hugo Beauzée-Luyssen

hw:d3d11: clean filter_sys_t usage

Might resulting in free an uninitialized pointer in case of error.

The compiler shouldn't have allowed this.

(cherry picked from commit adcbe60efe9b26cd88f27eaebbf7bccbb8b64e1a)
Signed-off-by: Hugo Beauzée-Luyssen <h...@beauzee.fr>

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

 modules/hw/d3d11/d3d11_surface.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 4bb2c750b5..f57ed230da 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -637,7 +637,6 @@ VIDEO_FILTER_WRAPPER (NV12_D3D11)
 int D3D11OpenConverter( vlc_object_t *obj )
 {
     filter_t *p_filter = (filter_t *)obj;
-    int err = VLC_EGENERIC;
 
     if ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE )
         return VLC_EGENERIC;
@@ -658,27 +657,20 @@ int D3D11OpenConverter( vlc_object_t *obj )
         return VLC_EGENERIC;
     }
 
-    filter_sys_t *p_sys = calloc(1, sizeof(filter_sys_t));
+    filter_sys_t *p_sys = vlc_obj_calloc(obj, 1, sizeof(filter_sys_t));
     if (!p_sys)
-         goto done;
+         return VLC_EGENERIC;
 
     if (D3D11_Create(p_filter, &p_sys->hd3d) != VLC_SUCCESS)
     {
         msg_Warn(p_filter, "cannot load d3d11.dll, aborting");
-        goto done;
+        return VLC_EGENERIC;
     }
 
     CopyInitCache(&p_sys->cache, p_filter->fmt_in.video.i_width );
     vlc_mutex_init(&p_sys->staging_lock);
     p_filter->p_sys = p_sys;
-    err = VLC_SUCCESS;
-
-done:
-    if (err != VLC_SUCCESS)
-    {
-        free(p_sys);
-    }
-    return err;
+    return VLC_SUCCESS;
 }
 
 int D3D11OpenCPUConverter( vlc_object_t *obj )
@@ -769,7 +761,7 @@ int D3D11OpenCPUConverter( vlc_object_t *obj )
             goto done;
     }
 
-    filter_sys_t *p_sys = calloc(1, sizeof(filter_sys_t));
+    filter_sys_t *p_sys = vlc_obj_calloc(obj, 1, sizeof(filter_sys_t));
     if (!p_sys) {
          err = VLC_ENOMEM;
          goto done;
@@ -795,7 +787,6 @@ done:
         if (texture)
             ID3D11Texture2D_Release(texture);
         D3D11_FilterReleaseInstance(&d3d_dev);
-        free(p_sys);
     }
     else
     {
@@ -824,8 +815,6 @@ void D3D11CloseConverter( vlc_object_t *obj )
         ID3D11Texture2D_Release(p_sys->staging);
     D3D11_FilterReleaseInstance(&p_sys->d3d_dev);
     D3D11_Destroy(&p_sys->hd3d);
-    free( p_sys );
-    p_filter->p_sys = NULL;
 }
 
 void D3D11CloseCPUConverter( vlc_object_t *obj )
@@ -835,6 +824,4 @@ void D3D11CloseCPUConverter( vlc_object_t *obj )
     DeleteFilter(p_sys->filter);
     picture_Release(p_sys->staging_pic);
     D3D11_Destroy(&p_sys->hd3d);
-    free( p_sys );
-    p_filter->p_sys = NULL;
 }

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to