From 713bbefd5edb05d455d00d248440ed0859a0763d Mon Sep 17 00:00:00 2001 From: Mark Hills Date: Sun, 6 Jun 2021 11:03:20 +0100 Subject: [PATCH] Fix a segfault when a TLS context is not used If the configuration contains entries such as: no-tlsv1 no-tlsv1_1 then the SSL context is NULL. The previous code was simple enough that it handled this case; the new code needs to deal with it explicitly. [*] https://github.com/coturn/coturn/issues/770 --- src/apps/relay/netengine.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/apps/relay/netengine.c b/src/apps/relay/netengine.c index 34f414c6..39214123 100644 --- a/src/apps/relay/netengine.c +++ b/src/apps/relay/netengine.c @@ -304,12 +304,17 @@ typedef struct update_ssl_ctx_cb_args { struct event *next; } update_ssl_ctx_cb_args_t; +/* + * Copy SSL context at "from", which may be NULL if no context in use + */ static void replace_one_ssl_ctx(SSL_CTX **to, SSL_CTX *from) { if (*to) SSL_CTX_free(*to); - if (from) + + if (from != NULL) SSL_CTX_up_ref(from); + *to = from; }