[gtk-vnc] vnc_connection_start_tls: add deinit label



commit e62d010777eecda47829e9da54bad3387f4d6231
Author: Ján Tomko <jtomko redhat com>
Date:   Fri Jan 11 16:34:30 2019 +0100

    vnc_connection_start_tls: add deinit label
    
    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 a1f7bb3..9ca8c32 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -4441,22 +4441,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;
@@ -4467,14 +4464,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;
             }
         }
 
@@ -4510,6 +4505,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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]