diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-11-06 11:03:05 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-11-08 08:20:06 +0000 |
commit | 668a144f0a6dcfb9f904043c29372cbf19856c39 (patch) | |
tree | 34134275b59d6eb49ca153f39d2d7b2035262886 /ssl | |
parent | 22fa1602da91af2194997e0576582bb4f0cdd7e0 (diff) |
Fix a possible memory leak in custom_ext_add
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22638)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/statem/extensions_cust.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ssl/statem/extensions_cust.c b/ssl/statem/extensions_cust.c index 8b296f1f59..7c049d2970 100644 --- a/ssl/statem/extensions_cust.c +++ b/ssl/statem/extensions_cust.c @@ -225,6 +225,9 @@ int custom_ext_add(SSL_CONNECTION *s, int context, WPACKET *pkt, X509 *x, || !WPACKET_start_sub_packet_u16(pkt) || (outlen > 0 && !WPACKET_memcpy(pkt, out, outlen)) || !WPACKET_close(pkt)) { + if (meth->free_cb != NULL) + meth->free_cb(SSL_CONNECTION_GET_SSL(s), meth->ext_type, context, + out, meth->add_arg); if (!for_comp) SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); return 0; @@ -234,6 +237,9 @@ int custom_ext_add(SSL_CONNECTION *s, int context, WPACKET *pkt, X509 *x, * We can't send duplicates: code logic should prevent this. */ if (!ossl_assert((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0)) { + if (meth->free_cb != NULL) + meth->free_cb(SSL_CONNECTION_GET_SSL(s), meth->ext_type, + context, out, meth->add_arg); if (!for_comp) SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); return 0; |