d243c14
From 5852d2efbfb888dfb0adddb25afac0814d3ebcbb Mon Sep 17 00:00:00 2001
d243c14
From: Michal Schmidt <mschmidt@redhat.com>
d243c14
Date: Tue, 17 Feb 2015 10:36:57 +0100
d243c14
Subject: [PATCH] journal-remote: fix client_cert memory leak
d243c14
d243c14
Found by Valgrind while testing the previous memory leak fix.
d243c14
d243c14
(cherry picked from commit 32c3d7144cf9a5c8c03761d7f198142ca0f5f7b8)
d243c14
---
d243c14
 src/journal-remote/microhttpd-util.c | 6 +++++-
d243c14
 1 file changed, 5 insertions(+), 1 deletion(-)
d243c14
d243c14
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
d243c14
index de9c6ab32d..a95fff18f3 100644
d243c14
--- a/src/journal-remote/microhttpd-util.c
d243c14
+++ b/src/journal-remote/microhttpd-util.c
d243c14
@@ -239,10 +239,14 @@ static int get_auth_dn(gnutls_x509_crt_t client_cert, char **buf) {
d243c14
         return 0;
d243c14
 }
d243c14
 
d243c14
+static inline void gnutls_x509_crt_deinitp(gnutls_x509_crt_t *p) {
d243c14
+        gnutls_x509_crt_deinit(*p);
d243c14
+}
d243c14
+
d243c14
 int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) {
d243c14
         const union MHD_ConnectionInfo *ci;
d243c14
         gnutls_session_t session;
d243c14
-        gnutls_x509_crt_t client_cert;
d243c14
+        _cleanup_(gnutls_x509_crt_deinitp) gnutls_x509_crt_t client_cert = NULL;
d243c14
         _cleanup_free_ char *buf = NULL;
d243c14
         int r;
d243c14