Restore old interface if TLS connection failed

This was reported as creating a segfault in [0]

[0] https://github.com/profanity-im/profanity/issues/1963

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel
2024-04-10 16:55:18 +02:00
parent 4359536a17
commit 9fef4b7d02

View File

@@ -1092,6 +1092,7 @@ int conn_tls_start(xmpp_conn_t *conn)
}
if (conn->tls != NULL) {
struct conn_interface old_intf = conn->intf;
conn->intf = tls_intf;
conn->intf.conn = conn;
if (tls_start(conn->tls)) {
@@ -1102,6 +1103,7 @@ int conn_tls_start(xmpp_conn_t *conn)
tls_free(conn->tls);
conn->tls = NULL;
conn->tls_failed = 1;
conn->intf = old_intf;
}
}
if (rc != 0) {