From c7cd8cec3f2b92a18a9295bf16e9c3c874c71825 Mon Sep 17 00:00:00 2001
From: Philipp Takacs <philipp@bureaucracy.de>
Date: Sat, 21 Mar 2026 14:33:54 +0100
Subject: [PATCH 4/6] free ldap attributes direct after used

this fix a double free
---
 table_ldap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/table_ldap.c b/table_ldap.c
index 71e1322..01d4ecb 100644
--- a/table_ldap.c
+++ b/table_ldap.c
@@ -222,6 +222,7 @@ ldap_lookup_entry(const struct request *req, const struct aldap_message *m)
 		if (strlcat(tmp, attr->str[1].ostr_val, sizeof(tmp)) > sizeof(tmp))
 			break;
 		table_api_lookup_result(req->id, req->s, tmp);
+		aldap_free_attr(attr);
 		break;
 	case K_USERINFO:
 		if (aldap_match_attr(m, q->attrs[0], &attr) == -1)
@@ -249,13 +250,12 @@ ldap_lookup_entry(const struct request *req, const struct aldap_message *m)
 		if (strlcat(tmp, attr->str[1].ostr_val, sizeof(tmp)) > sizeof(tmp))
 			break;
 		table_api_lookup_result(req->id, req->s, tmp);
+		aldap_free_attr(attr);
 		break;
 	default:
 		log_warnx("unhandled service");
 		break;
 	}
-
-	aldap_free_attr(attr);
 }
 
 static void
-- 
2.52.0

