[vlc-commits] livehttp: fix many memory leaks

Rémi Duraffort git at videolan.org
Sun Dec 15 22:03:30 CET 2013


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sat Dec 14 10:47:01 2013 +0100| [bbf068ed1767033545045a3ec2a1de46b059fd74] | committer: Rémi Duraffort

livehttp: fix many memory leaks

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

 modules/access_output/livehttp.c |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index 608c122..517645a 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -308,16 +308,23 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file )
     uint8_t key[16];
     char *keyfile = NULL;
 
+    if( !p_sys->key_uri ) /*No key uri, assume no encryption wanted*/
+    {
+        msg_Dbg( p_access, "No key uri, no encryption");
+        return VLC_SUCCESS;
+    }
+
     if( key_file )
         keyfile = strdup( key_file );
     else
         keyfile = var_InheritString( p_access, SOUT_CFG_PREFIX "key-file" );
 
-    if( !p_sys->key_uri ) /*No key uri, assume no encryption wanted*/
+    if( unlikely(keyfile == NULL) )
     {
-        msg_Dbg( p_access, "No key uri, no encryption");
-        return VLC_SUCCESS;
+        msg_Err( p_access, "No key-file, no encryption" );
+        return VLC_EGENERIC;
     }
+
     vlc_gcrypt_init();
 
     /*Setup encryption cipher*/
@@ -326,12 +333,7 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file )
     if( err )
     {
         msg_Err( p_access, "Openin AES Cipher failed: %s", gpg_strerror(err));
-        return VLC_EGENERIC;
-    }
-
-    if( unlikely(keyfile == NULL) )
-    {
-        msg_Err( p_access, "No key-file, no encryption" );
+        free( key_file );
         return VLC_EGENERIC;
     }
 
@@ -340,6 +342,7 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file )
     {
         msg_Err( p_access, "Unable to open keyfile %s: %m", keyfile );
         free( keyfile );
+        gcry_cipher_close( p_sys->aes_ctx );
         return VLC_EGENERIC;
     }
     free( keyfile );
@@ -350,6 +353,7 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file )
     if( keylen < 16 )
     {
         msg_Err( p_access, "No key at least 16 octects (you provided %zd), no encryption", keylen );
+        gcry_cipher_close( p_sys->aes_ctx );
         return VLC_EGENERIC;
     }
 
@@ -357,7 +361,7 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file )
     if(err)
     {
         msg_Err(p_access, "Setting AES key failed: %s", gpg_strerror(err));
-        gcry_cipher_close( p_sys->aes_ctx);
+        gcry_cipher_close( p_sys->aes_ctx );
         return VLC_EGENERIC;
     }
 



More information about the vlc-commits mailing list