From b185449d073b376eb305ff2a68d87fd82ed56377 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 9 Jan 2014 21:20:45 +0000 Subject: Fix a memory/fd leak reported by Tiago Cunha. --- client.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 1458963c..4cf73fb9 100644 --- a/client.c +++ b/client.c @@ -118,10 +118,15 @@ retry: close(fd); xasprintf(&lockfile, "%s.lock", path); - if ((lockfd = client_get_lock(lockfile)) == -1) + if ((lockfd = client_get_lock(lockfile)) == -1) { + free(lockfile); goto retry; - if (unlink(path) != 0 && errno != ENOENT) + } + if (unlink(path) != 0 && errno != ENOENT) { + free(lockfile); + close(lockfd); return (-1); + } fd = server_start(lockfd, lockfile); free(lockfile); close(lockfd); -- cgit v1.2.3