summaryrefslogtreecommitdiffstats
path: root/ssl/ssl_sess.c
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2023-07-02 17:19:17 +1000
committerPauli <pauli@openssl.org>2023-07-05 08:34:00 +1000
commit97beb77f319f119957235233396627bb22283da0 (patch)
treee2c58f0b0e46f90ca732da86e9a315a781622ed9 /ssl/ssl_sess.c
parent52c362b3fe5ab9b1c44ec560820b242eb3df0e3b (diff)
fix memory allocation and reference counting issues
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/21341)
Diffstat (limited to 'ssl/ssl_sess.c')
-rw-r--r--ssl/ssl_sess.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c
index 486d938c94..3dcc4d81e5 100644
--- a/ssl/ssl_sess.c
+++ b/ssl/ssl_sess.c
@@ -141,9 +141,8 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
SSL_SESSION *dest;
dest = OPENSSL_malloc(sizeof(*dest));
- if (dest == NULL) {
- goto err;
- }
+ if (dest == NULL)
+ return NULL;
memcpy(dest, src, sizeof(*dest));
/*
@@ -171,8 +170,10 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
dest->next = NULL;
dest->owner = NULL;
- if (!CRYPTO_NEW_REF(&dest->references, 1))
- goto err;
+ if (!CRYPTO_NEW_REF(&dest->references, 1)) {
+ OPENSSL_free(dest);
+ return NULL;
+ }
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, dest, &dest->ex_data)) {
ERR_raise(ERR_LIB_SSL, ERR_R_CRYPTO_LIB);