[glib-networking] gnutls: fix leak of base stream (or base datagram socket)



commit c5d965b2bca63bed1edaf96b973af6fdb7c973e7
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Dec 29 18:19:46 2019 -0600

    gnutls: fix leak of base stream (or base datagram socket)
    
    We leak the base GIOStream or GDatagramBased in
    g_tls_connection_gnutls_initable_init. Oops.

 tls/gnutls/gtlsconnection-gnutls.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 94c5620..39cc7c5 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -141,6 +141,8 @@ g_tls_connection_gnutls_initable_init (GInitable     *initable,
       g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
                    _("Could not create TLS connection: %s"),
                    gnutls_strerror (ret));
+      g_clear_object (&base_io_stream);
+      g_clear_object (&base_socket);
       return FALSE;
     }
 
@@ -157,6 +159,8 @@ g_tls_connection_gnutls_initable_init (GInitable     *initable,
       g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
                    _("Could not create TLS connection: %s"),
                    gnutls_strerror (status));
+      g_clear_object (&base_io_stream);
+      g_clear_object (&base_socket);
       return FALSE;
     }
 
@@ -179,6 +183,9 @@ g_tls_connection_gnutls_initable_init (GInitable     *initable,
   if (flags & GNUTLS_DATAGRAM)
     gnutls_dtls_set_mtu (priv->session, 1400);
 
+  g_clear_object (&base_io_stream);
+  g_clear_object (&base_socket);
+
   return TRUE;
 }
 


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