aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/gloox.rb
blob: 6b7f22e97d11d22069175ed097760eb76909bfb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require 'formula'

class Gloox < Formula
  homepage 'http://camaya.net/gloox/'
  url 'http://camaya.net/download/gloox-1.0.tar.bz2'
  md5 'f8eacf1c6476e0a309b453fd04f90e31'

  depends_on 'pkg-config' => :build

  # Fix memory leak
  # http://bugs.camaya.net/horde/whups/ticket/?id=181
  # Issue tracker is 404 on 3/17/2012 - @adamv
  def patches; DATA; end

  def install
    system "./configure", "--disable-debug",
                          "--prefix=#{prefix}",
                          "--with-openssl",
                          "--without-gnutls",
                          "--with-zlib"
    system "make install"
  end
end

__END__
diff --git a/src/tlsgnutlsbase.cpp b/src/tlsgnutlsbase.cpp
index d98c802..37f702d 100644
--- a/src/tlsgnutlsbase.cpp
+++ b/src/tlsgnutlsbase.cpp
@@ -97,7 +97,7 @@ namespace gloox
     gnutls_bye( *m_session, GNUTLS_SHUT_RDWR );
     gnutls_db_remove_session( *m_session );
     gnutls_credentials_clear( *m_session );
-    if( m_secure )
+    if( m_session )
       gnutls_deinit( *m_session );
 
     m_secure = false;
diff --git a/src/tlsgnutlsclient.cpp b/src/tlsgnutlsclient.cpp
index c1d24c2..d250f32 100644
--- a/src/tlsgnutlsclient.cpp
+++ b/src/tlsgnutlsclient.cpp
@@ -33,6 +33,8 @@ namespace gloox
   void GnuTLSClient::cleanup()
   {
     GnuTLSBase::cleanup();
+    if (m_credentials)
+        gnutls_certificate_free_credentials( m_credentials );
     init();
   }
 
@@ -120,6 +122,7 @@ namespace gloox
       m_certInfo.status |= CertSignerNotCa;
     const gnutls_datum_t* certList = 0;
     unsigned int certListSize;
+    unsigned int certListSizeFull;
     if( !error && ( ( certList = gnutls_certificate_get_peers( *m_session, &certListSize ) ) == 0 ) )
       error = true;
 
@@ -131,6 +134,7 @@ namespace gloox
         error = true;
     }
 
+    certListSizeFull = certListSize;
     if( ( gnutls_x509_crt_check_issuer( cert[certListSize-1], cert[certListSize-1] ) > 0 )
          && certListSize > 0 )
       certListSize--;
@@ -189,7 +193,7 @@ namespace gloox
     if( !gnutls_x509_crt_check_hostname( cert[0], m_server.c_str() ) )
       m_certInfo.status |= CertWrongPeer;
 
-    for( unsigned int i = 0; i < certListSize; ++i )
+    for( unsigned int i = 0; i < certListSizeFull; ++i )
       gnutls_x509_crt_deinit( cert[i] );
 
     delete[] cert;