ryantimwilson / rpms / systemd

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