From 4bdd43fdca20c5162e0cb297f287d9235f151c43 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 15 Jul 2024 20:39:04 +0200 Subject: [PATCH] dotlock: Avoid leaking directory handle. * common/dotlock.c (dotlock_detect_tname): Close directory on errors. -- GnuPG-bug-id: 7201 Signed-off-by: Jakub Jelen --- common/dotlock.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/dotlock.c b/common/dotlock.c index ae77fad8a..19611ab7a 100644 --- a/common/dotlock.c +++ b/common/dotlock.c @@ -724,6 +724,7 @@ dotlock_detect_tname (dotlock_t h) if (dlen > len) { + closedir (dir); xfree (basename); xfree (dirname); return -1; @@ -734,6 +735,7 @@ dotlock_detect_tname (dotlock_t h) tname_path = strchr (h->tname + strlen (dirname) + 2, '.'); if (!tname_path) { + closedir (dir); xfree (basename); xfree (dirname); return -1;