[vlc-commits] securetransport: fix memory leak in error paths

David Fuhrmann git at videolan.org
Tue Feb 25 18:47:37 CET 2014


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Tue Feb 25 13:43:15 2014 +0100| [08b6366941a67cb5a5bb037fde351522f7347ca3] | committer: David Fuhrmann

securetransport: fix memory leak in error paths

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

 modules/misc/securetransport.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/misc/securetransport.c b/modules/misc/securetransport.c
index b504d6b..2072fe8 100644
--- a/modules/misc/securetransport.c
+++ b/modules/misc/securetransport.c
@@ -701,10 +701,6 @@ static int OpenServer (vlc_tls_creds_t *crd, const char *cert, const char *key)
 
     msg_Dbg(crd, "open st server");
 
-    vlc_tls_creds_sys_t *sys = malloc(sizeof(*sys));
-    if (unlikely(sys == NULL))
-        return VLC_ENOMEM;
-
     /*
      * Get the server certificate.
      *
@@ -785,6 +781,12 @@ static int OpenServer (vlc_tls_creds_t *crd, const char *cert, const char *key)
         CFArrayAppendArray(server_cert_chain, cert_chain, CFRangeMake(1, num_cert_chain - 1));
     CFRelease(cert_chain);
 
+    vlc_tls_creds_sys_t *sys = malloc(sizeof(*sys));
+    if (unlikely(sys == NULL)) {
+        CFRelease(server_cert_chain);
+        result = VLC_ENOMEM;
+        goto out;
+    }
 
     sys->server_cert_chain = server_cert_chain;
     sys->whitelist = NULL;



More information about the vlc-commits mailing list