From b298322d36d4fc9a8d86515410e1d3f2cddea19f Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 20 Dec 2023 10:53:50 +0900 Subject: [PATCH] common: Clean up the temporary file at dotlock_destroy. * common/dotlock.c (dotlock_destroy): Clean up the temporary file created when it fails. -- Signed-off-by: NIIBE Yutaka --- common/dotlock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/dotlock.c b/common/dotlock.c index 84d0b509c..fe6d7fe71 100644 --- a/common/dotlock.c +++ b/common/dotlock.c @@ -1213,6 +1213,12 @@ dotlock_destroy (dotlock_t h) } #ifdef HAVE_POSIX_SYSTEM + /* When DOTLOCK_LOCK_BY_PARENT and lock fails, + the temporary file created should be removed. */ + if (h->by_parent && !h->no_write && !h->locked) + if (h->tname && !h->use_o_excl) + unlink (h->tname); + xfree (h->tname); #endif xfree (h->lockname);