summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2014-07-15 10:09:55 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2014-07-15 10:47:28 +0200
commit8094cbbe0b64da9bc251177c4ddcc82a90979071 (patch)
tree291cd14e15218c6e9e5bf7aee25dc722d4cb6f59
parentdc63c9a25745ce9d46671af3fdfb1255f54cf6ad (diff)
downloadneon-8094cbbe0b64da9bc251177c4ddcc82a90979071.tar.gz
neon-8094cbbe0b64da9bc251177c4ddcc82a90979071.tar.bz2
neon-8094cbbe0b64da9bc251177c4ddcc82a90979071.zip
gnutls: fix memory leak when using gnutls >= 1.3.1
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>
-rw-r--r--src/ne_gnutls.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ne_gnutls.c b/src/ne_gnutls.c
index 08d78cc..485b9de 100644
--- a/src/ne_gnutls.c
+++ b/src/ne_gnutls.c
@@ -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);