summaryrefslogtreecommitdiffstats
path: root/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authordoug <doug@openbsd.org>2015-10-03 06:47:32 +0000
committerdoug <doug@openbsd.org>2015-10-03 06:47:32 +0000
commit34b6114d4785415960702fe6531e4b7621757dc0 (patch)
tree0d1b6ff8e731471ce7c87a61745fa21639acff2c /lib/libssl/ssl_lib.c
parentgrep only opens files read-only, reads via stdio or other methods, performs (diff)
downloadwireguard-openbsd-34b6114d4785415960702fe6531e4b7621757dc0.tar.xz
wireguard-openbsd-34b6114d4785415960702fe6531e4b7621757dc0.zip
SSL_new(): fix ref counting and memory leak in error path.
Rather than a half-hearted attempt to free up resources and fix ref counting at the SSL_CTX level, let SSL_free() do its job. This diff got lost in the shuffle somewhere. It's from last year. Ref counting error reported by Parakleta in github ticket #51. Thanks! ok jsing@, beck@
Diffstat (limited to 'lib/libssl/ssl_lib.c')
-rw-r--r--lib/libssl/ssl_lib.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c
index b772f5f8105..0b094e8db6b 100644
--- a/lib/libssl/ssl_lib.c
+++ b/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_lib.c,v 1.112 2015/09/12 19:45:16 jsing Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.113 2015/10/03 06:47:32 doug Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -359,15 +359,10 @@ SSL_new(SSL_CTX *ctx)
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);
-
return (s);
+
err:
- if (s != NULL) {
- if (s->cert != NULL)
- ssl_cert_free(s->cert);
- SSL_CTX_free(s->ctx); /* decrement reference count */
- free(s);
- }
+ SSL_free(s);
SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}