From 5488ad0517422b31a7be46a7575f5f5492e9fee1 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 20 Dec 2023 10:28:02 +0900 Subject: [PATCH] common: Fix a possible resource leak for dotlock. * common/dotlock.c (dotlock_destroy_unix): Don't release ->TNAME here. (dotlock_destroy): Release the memory unconditionally. -- Signed-off-by: NIIBE Yutaka --- common/dotlock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/dotlock.c b/common/dotlock.c index f4d7243e0..06e3910ad 100644 --- a/common/dotlock.c +++ b/common/dotlock.c @@ -1155,7 +1155,6 @@ dotlock_destroy_unix (dotlock_t h) unlink (h->lockname); if (h->tname && !h->use_o_excl) unlink (h->tname); - xfree (h->tname); } #endif /*HAVE_POSIX_SYSTEM*/ @@ -1208,8 +1207,12 @@ dotlock_destroy (dotlock_t h) #else /* !HAVE_DOSISH_SYSTEM */ dotlock_destroy_unix (h); #endif /* HAVE_DOSISH_SYSTEM */ - xfree (h->lockname); } + +#ifdef HAVE_POSIX_SYSTEM + xfree (h->tname); +#endif + xfree (h->lockname); xfree(h); }