[vlc-commits] es: use vlc_obj_malloc() and check for errors

Rémi Denis-Courmont git at videolan.org
Sun Apr 19 13:17:33 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 19 14:15:02 2020 +0300| [00599fa19d948c5a2b8b4e8de7e409a40ccf3d30] | committer: Rémi Denis-Courmont

es: use vlc_obj_malloc() and check for errors

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

 modules/stream_out/es.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/stream_out/es.c b/modules/stream_out/es.c
index d5c41b3ec6..70092e7034 100644
--- a/modules/stream_out/es.c
+++ b/modules/stream_out/es.c
@@ -281,10 +281,12 @@ static const char *const ppsz_sout_options[] = {
 static int Open( vlc_object_t *p_this )
 {
     sout_stream_t       *p_stream = (sout_stream_t*)p_this;
-    sout_stream_sys_t   *p_sys;
+    sout_stream_sys_t *p_sys = vlc_obj_malloc(p_this, sizeof (*p_sys));
+
+    if (unlikely(p_sys == NULL))
+        return VLC_ENOMEM;
 
     config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg );
-    p_sys                   = malloc( sizeof( sout_stream_sys_t ) );
 
     p_sys->i_count          = 0;
     p_sys->i_count_audio    = 0;
@@ -331,8 +333,6 @@ static void Close( vlc_object_t * p_this )
     free( p_sys->psz_dst );
     free( p_sys->psz_dst_audio );
     free( p_sys->psz_dst_video );
-
-    free( p_sys );
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list