From 710d227daaf4833135344690ed32ca58e91b10d6 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Sun, 11 Jan 2015 20:07:59 -0500 Subject: [PATCH] Fix memory leak in SSL_new if errors occur. (Imported from upstream's 76e6509085ea96df0ca542568ee2596343711307) Change-Id: I6319271a1f46b3d36a4eba950cbab60420126175 Reviewed-on: https://boringssl-review.googlesource.com/2833 Reviewed-by: Adam Langley --- ssl/ssl_lib.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index d179dc85..311c1e4d 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -374,13 +374,7 @@ SSL *SSL_new(SSL_CTX *ctx) { err: if (s != NULL) { - if (s->cert != NULL) { - ssl_cert_free(s->cert); - } - if (s->ctx != NULL) { - SSL_CTX_free(s->ctx); - } - OPENSSL_free(s); + SSL_free(s); } OPENSSL_PUT_ERROR(SSL, SSL_new, ERR_R_MALLOC_FAILURE);