File 0002-codec-x264-fix-leak-on-error.patch of Package vlc.9728

From 25fe1cbf93c0c49882465fed0fbec5ea450684ba Mon Sep 17 00:00:00 2001
From: Zhao Zhili <quinkblack@foxmail.com>
Date: Mon, 27 Aug 2018 17:41:31 +0800
Subject: [PATCH] codec: x264: fix leak on error

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
---
 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 19eed66ee0c..0efd8020cf4 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 );
 }
openSUSE Build Service is sponsored by