From 1121a3fcb7c360eaa345d17891e0a243082d4f71 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 16 Nov 2003 23:54:52 +0000 Subject: [PATCH] Fixed some memory leaks. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3162 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/network-openssl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c index 2304ef4e..acab35f1 100644 --- a/src/core/network-openssl.c +++ b/src/core/network-openssl.c @@ -530,7 +530,6 @@ static GIOChannel *irssi_ssl_get_iochannel(GIOChannel *handle, const char *mycer chan->ctx = ctx; chan->got_cert = cert != NULL; chan->verify = verify; - g_io_channel_ref(handle); gchan = (GIOChannel *)chan; gchan->funcs = &irssi_ssl_channel_funcs; @@ -541,9 +540,13 @@ static GIOChannel *irssi_ssl_get_iochannel(GIOChannel *handle, const char *mycer GIOChannel *net_connect_ip_ssl(IPADDR *ip, int port, IPADDR *my_ip, const char *cert, const char *pkey, const char *cafile, const char *capath, gboolean verify) { - GIOChannel *gret = net_connect_ip(ip, port, my_ip); - gret = irssi_ssl_get_iochannel(gret, cert, pkey, cafile, capath, verify); - return gret; + GIOChannel *handle, *ssl_handle; + + handle = net_connect_ip(ip, port, my_ip); + ssl_handle = irssi_ssl_get_iochannel(handle, cert, pkey, cafile, capath, verify); + if (ssl_handle == NULL) + g_io_channel_unref(handle); + return ssl_handle; } #else /* HAVE_OPENSSL */