Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-05-16 15:05:24 +0300
committerJunio C Hamano <gitster@pobox.com>2021-05-16 15:05:24 +0300
commit94294e92e107009f96c7496387717e618dc249c4 (patch)
tree65543aab88525a6f598781d4c5e944a5c9532a3e /builtin
parentcaf6840be0157adc2eb3f19d080b2ab2e0101c9e (diff)
parentc5d0b12a4c8aaf4a1d317a2fa589d30255f5bc80 (diff)
Merge branch 'lh/maintenance-leakfix'
* lh/maintenance-leakfix: maintenance: fix two memory leaks
Diffstat (limited to 'builtin')
-rw-r--r--builtin/gc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 98a803196b..f05d2f0a1a 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1909,6 +1909,7 @@ static int crontab_update_schedule(int run_maintenance, int fd, const char *cmd)
else if (!in_old_region)
fprintf(cron_in, "%s\n", line.buf);
}
+ strbuf_release(&line);
if (run_maintenance) {
struct strbuf line_format = STRBUF_INIT;
@@ -1971,8 +1972,10 @@ static int update_background_schedule(int enable)
cmd = sep + 1;
}
- if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0)
- return error(_("another process is scheduling background maintenance"));
+ if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
+ result = error(_("another process is scheduling background maintenance"));
+ goto cleanup;
+ }
if (!strcmp(scheduler, "launchctl"))
result = launchctl_update_schedule(enable, get_lock_file_fd(&lk), cmd);
@@ -1984,6 +1987,9 @@ static int update_background_schedule(int enable)
die("unknown background scheduler: %s", scheduler);
rollback_lock_file(&lk);
+
+cleanup:
+ free(lock_path);
free(testing);
return result;
}