Fix memory leak in SSL_new if errors occur.
authorMatt Caswell <matt@openssl.org>
Thu, 4 Dec 2014 09:46:44 +0000 (09:46 +0000)
committerMatt Caswell <matt@openssl.org>
Mon, 8 Dec 2014 16:44:09 +0000 (16:44 +0000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 76e6509085ea96df0ca542568ee2596343711307)

ssl/ssl_lib.c

index 51a0ef7ca6abdbb92c065605c92cad7bf1a7d21e..8f49a6f184a0302ff36cb54a886275c6a12f3d0e 100644 (file)
@@ -416,13 +416,7 @@ SSL *SSL_new(SSL_CTX *ctx)
        return(s);
 err:
        if (s != NULL)
-               {
-               if (s->cert != NULL)
-                       ssl_cert_free(s->cert);
-               if (s->ctx != NULL)
-                       SSL_CTX_free(s->ctx); /* decrement reference count */
-               OPENSSL_free(s);
-               }
+               SSL_free(s);
        SSLerr(SSL_F_SSL_NEW,ERR_R_MALLOC_FAILURE);
        return(NULL);
        }