gnutls: fix memory leak when using gnutls >= 1.3.1 84/24484/1
authorPatrick Ohly <patrick.ohly@intel.com>
Tue, 15 Jul 2014 08:09:55 +0000 (10:09 +0200)
committerPatrick Ohly <patrick.ohly@intel.com>
Tue, 15 Jul 2014 08:47:28 +0000 (10:47 +0200)
When using gnutls_session_get_data2() to allocate
ctx->cache.client.data, we must free it with gnutls_free to deallocate
it.

When using an older gnutls without that method, we allocate the data
ourselves and must continue to use ne_free().

Originally reported by Werner Baumann.

Change-Id: Ifdfa9916f488767f8d501fd083cce3cfd9c7ba74
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
src/ne_gnutls.c

index 08d78cc..485b9de 100644 (file)
@@ -694,7 +694,11 @@ void ne_ssl_context_destroy(ne_ssl_context *ctx)
 {
     gnutls_certificate_free_credentials(ctx->cred);
     if (ctx->cache.client.data) {
+#if defined(HAVE_GNUTLS_SESSION_GET_DATA2)
+        gnutls_free(ctx->cache.client.data);
+#else
         ne_free(ctx->cache.client.data);
+#endif
     } else if (ctx->cache.server.key.data) {
         gnutls_free(ctx->cache.server.key.data);
         gnutls_free(ctx->cache.server.data.data);