]> git.sesse.net Git - vlc/commitdiff
securetransport: fix memory leak in error paths
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Tue, 25 Feb 2014 12:43:15 +0000 (13:43 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Tue, 25 Feb 2014 17:45:56 +0000 (18:45 +0100)
modules/misc/securetransport.c

index b504d6b9ef98dcd732e36294ad99199bcc668283..2072fe8baa410946c915bceed65c9305ef72bc81 100644 (file)
@@ -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;