From f9939490ebdba403462b6839d29fdc6837d8a0ec Mon Sep 17 00:00:00 2001
From: Azat Khuzhin <azat@libevent.org>
Date: Sun, 18 Feb 2024 21:19:41 +0100
Subject: [PATCH] Fix leak in evconnlistener_new_async()

Fixes: https://github.com/libevent/libevent/issues/414

---
 listener.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/listener.c b/listener.c
index f5c00c9..01dc41d 100644
--- a/listener.c
+++ b/listener.c
@@ -885,8 +885,11 @@ evconnlistener_new_async(struct event_base *base,
 	return &lev->base;
 
 err_free_accepting:
+	for (i = 0; i < lev->n_accepting; ++i) {
+		if (lev->accepting[i])
+			free_and_unlock_accepting_socket(lev->accepting[i]);
+	}
 	mm_free(lev->accepting);
-	/* XXXX free the other elements. */
 err_delete_lock:
 	EVTHREAD_FREE_LOCK(lev->base.lock, EVTHREAD_LOCKTYPE_RECURSIVE);
 err_free_lev:
-- 
2.27.0

