From abb274b154a14aaed30e4226abe98246df5c6fc6 Mon Sep 17 00:00:00 2001 From: Jack Lau Date: Sat, 12 Jul 2025 17:03:02 +0800 Subject: [PATCH] avformat/tls_openssl: make tls and dtls use one close function Signed-off-by: Jack Lau Signed-off-by: Timo Rothenpieler --- libavformat/tls_openssl.c | 18 +++--------------- 1 file 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,