a2a7378
From a543b200cdd1e798383cc1070e51ad13ff424543 Mon Sep 17 00:00:00 2001
a2a7378
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
a2a7378
Date: Tue, 5 Nov 2019 12:11:14 +0100
a2a7378
Subject: [PATCH] warnquota: Free LDAP error message
a2a7378
MIME-Version: 1.0
a2a7378
Content-Type: text/plain; charset=UTF-8
a2a7378
Content-Transfer-Encoding: 8bit
a2a7378
a2a7378
ldap_get_option(3) documents that a pointer set by
a2a7378
LDAP_OPT_DIAGNOSTIC_MESSAGE must be freed with ldap_memfree(3).
a2a7378
a2a7378
Signed-off-by: Petr Písař <ppisar@redhat.com>
a2a7378
---
a2a7378
 warnquota.c | 5 ++++-
a2a7378
 1 file changed, 4 insertions(+), 1 deletion(-)
a2a7378
a2a7378
diff --git a/warnquota.c b/warnquota.c
a2a7378
index d54b4c1..f6b42d5 100644
a2a7378
--- a/warnquota.c
a2a7378
+++ b/warnquota.c
a2a7378
@@ -190,8 +190,11 @@ static void print_ldap_error(int err, char *prefix)
a2a7378
 	sstrncat(outbuf, ": %s\n", LDAP_ERR_BUF_SIZE);
a2a7378
 	errstr(outbuf, ldap_err2string(err));
a2a7378
 	ldap_get_option(ldapconn, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void *)&msg;;
a2a7378
-	if (msg && strcmp(msg, ""))
a2a7378
+	if (msg) {
a2a7378
+	    if (strcmp(msg, ""))
a2a7378
 		errstr(_("Additional error info: %s\n"), msg);
a2a7378
+	    ldap_memfree(msg);
a2a7378
+	}
a2a7378
 }
a2a7378
 
a2a7378
 static int setup_ldap(struct configparams *config)
a2a7378
-- 
a2a7378
2.21.0
a2a7378