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 <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2023-12-20 10:53:50 +09:00
parent 2f6fec3f48
commit b298322d36
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054
1 changed files with 6 additions and 0 deletions

View File

@ -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);