aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/tls_openssl.c
diff options
context:
space:
mode:
authorJack Lau <jacklau1222@qq.com>2025-07-12 17:03:02 +0800
committerTimo Rothenpieler <timo@rothenpieler.org>2025-07-17 14:04:32 +0200
commitabb274b154a14aaed30e4226abe98246df5c6fc6 (patch)
treec63b45488e9070c97fcaaed2b60d2805a98006b6 /libavformat/tls_openssl.c
parentbc8d06d54188a3c1ba878b7e0bca66b9e4b3ceea (diff)
downloadffmpeg-abb274b154a14aaed30e4226abe98246df5c6fc6.tar.gz
avformat/tls_openssl: make tls and dtls use one close function
Signed-off-by: Jack Lau <jacklau1222@qq.com> Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavformat/tls_openssl.c')
-rw-r--r--libavformat/tls_openssl.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 2a969b27f1..780867ab79 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -578,7 +578,8 @@ static int tls_close(URLContext *h)
}
if (c->ctx)
SSL_CTX_free(c->ctx);
- ffurl_closep(&c->tls_shared.tcp);
+ if (!c->tls_shared.external_sock)
+ ffurl_closep(c->tls_shared.is_dtls ? &c->tls_shared.udp : &c->tls_shared.tcp);
if (c->url_bio_method)
BIO_meth_free(c->url_bio_method);
return 0;
@@ -908,19 +909,6 @@ fail:
return ret;
}
-/**
- * Cleanup the DTLS context.
- */
-static av_cold int dtls_close(URLContext *h)
-{
- TLSContext *ctx = h->priv_data;
- SSL_free(ctx->ssl);
- SSL_CTX_free(ctx->ctx);
- av_freep(&ctx->tls_shared.cert_buf);
- av_freep(&ctx->tls_shared.key_buf);
- return 0;
-}
-
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
{
TLSContext *p = h->priv_data;
@@ -1069,7 +1057,7 @@ const URLProtocol ff_dtls_protocol = {
.name = "dtls",
.url_open2 = dtls_start,
.url_handshake = dtls_handshake,
- .url_close = dtls_close,
+ .url_close = tls_close,
.url_read = tls_read,
.url_write = tls_write,
.url_get_file_handle = tls_get_file_handle,