From: yangyangtiantianlonglong Date: Mon, 31 Jul 2023 14:04:41 +0000 (-0700) Subject: A null pointer dereference occurs when memory allocation fails X-Git-Tag: openssl-3.1.3~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52e5e8b1e1055f20cdeb9148e78ad31007a8aa49;p=thirdparty%2Fopenssl.git A null pointer dereference occurs when memory allocation fails Fixes #21605 Reviewed-by: Hugo Landau Reviewed-by: Matthias St. Pierre Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/21606) (cherry picked from commit a8da305fa3dd6e34ba5aab3978281f652fd12883) --- diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 90aec2badac..bf84e792251 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -200,8 +200,11 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket) dest->references = 1; dest->lock = CRYPTO_THREAD_lock_new(); - if (dest->lock == NULL) + if (dest->lock == NULL) { + OPENSSL_free(dest); + dest = NULL; goto err; + } if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, dest, &dest->ex_data)) goto err;