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 <agl@google.com>
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index d179dc8..311c1e4 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -374,13 +374,7 @@
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);