[PATCH 1/3] vnc_connection_start_tls: add deinit label
- From: Ján Tomko <jtomko redhat com>
- To: gtk-vnc-list gnome org
- Subject: [PATCH 1/3] vnc_connection_start_tls: add deinit label
- Date: Fri, 11 Jan 2019 16:34:30 +0100
Introduce a deinit label to unify cleanup paths which call gnutls_deinit.
Signed-off-by: Ján Tomko <jtomko redhat com>
---
src/vncconnection.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/vncconnection.c b/src/vncconnection.c
index f9c510a..898f841 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -4433,22 +4433,19 @@ static gboolean vnc_connection_start_tls(VncConnection *conn, int anonTLS)
}
if (gnutls_priority_set_direct(priv->tls_session, priority, NULL) < 0) {
- gnutls_deinit(priv->tls_session);
vnc_connection_set_error(conn, "%s", "Failed to set priority");
- return FALSE;
+ goto deinit;
}
if (anonTLS) {
gnutls_anon_client_credentials anon_cred = vnc_connection_tls_initialize_anon_cred();
if (!anon_cred) {
- gnutls_deinit(priv->tls_session);
vnc_connection_set_error(conn, "%s", "Failed to allocate credentials");
- return FALSE;
+ goto deinit;
}
if (gnutls_credentials_set(priv->tls_session, GNUTLS_CRD_ANON, anon_cred) < 0) {
- gnutls_deinit(priv->tls_session);
vnc_connection_set_error(conn, "%s", "Failed to initialize credentials");
- return FALSE;
+ goto deinit;
}
} else {
priv->want_cred_password = FALSE;
@@ -4459,14 +4456,12 @@ static gboolean vnc_connection_start_tls(VncConnection *conn, int anonTLS)
gnutls_certificate_credentials_t x509_cred = vnc_connection_tls_initialize_cert_cred(conn);
if (!x509_cred) {
- gnutls_deinit(priv->tls_session);
vnc_connection_set_error(conn, "%s", "Failed to allocate credentials");
- return FALSE;
+ goto deinit;
}
if (gnutls_credentials_set(priv->tls_session, GNUTLS_CRD_CERTIFICATE, x509_cred) < 0) {
- gnutls_deinit(priv->tls_session);
vnc_connection_set_error(conn, "%s", "Failed to initialize credentials");
- return FALSE;
+ goto deinit;
}
}
@@ -4502,6 +4497,10 @@ static gboolean vnc_connection_start_tls(VncConnection *conn, int anonTLS)
}
return TRUE;
}
+
+ deinit:
+ gnutls_deinit(priv->tls_session);
+ return FALSE;
}
static gboolean vnc_connection_has_auth_subtype(gpointer data)
--
2.20.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]