[vlc-commits] codec: x264: fix leak on error

Zhao Zhili git at videolan.org
Wed Aug 29 12:02:34 CEST 2018


vlc | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Mon Aug 27 17:41:31 2018 +0800| [25fe1cbf93c0c49882465fed0fbec5ea450684ba] | committer: Jean-Baptiste Kempf

codec: x264: fix leak on error

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/x264.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/modules/codec/x264.c b/modules/codec/x264.c
index 19eed66ee0..0efd8020cf 100644
--- a/modules/codec/x264.c
+++ b/modules/codec/x264.c
@@ -811,7 +811,7 @@ static int  Open ( vlc_object_t *p_this )
 #else
     p_enc->fmt_out.i_codec = VLC_CODEC_H264;
 #endif
-    p_enc->p_sys = p_sys = malloc( sizeof( encoder_sys_t ) );
+    p_enc->p_sys = p_sys = vlc_obj_malloc( p_this, sizeof( encoder_sys_t ) );
     if( !p_sys )
         return VLC_ENOMEM;
 
@@ -847,6 +847,7 @@ static int  Open ( vlc_object_t *p_this )
         else
         {
             msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
+            free( psz_profile );
             return VLC_EGENERIC;
         }
 # endif
@@ -854,8 +855,8 @@ static int  Open ( vlc_object_t *p_this )
 # ifdef MODULE_NAME_IS_x26410b
     else
     {
-            msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
-            return VLC_EGENERIC;
+        msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
+        return VLC_EGENERIC;
     }
 # endif
     free( psz_profile );
@@ -1583,6 +1584,4 @@ static void Close( vlc_object_t *p_this )
 
     vlc_mutex_unlock( &pthread_win32_mutex );
 #endif
-
-    free( p_sys );
 }



More information about the vlc-commits mailing list