Skip to content

Commit 94294e9

Browse files
committed
Merge branch 'lh/maintenance-leakfix'
* lh/maintenance-leakfix: maintenance: fix two memory leaks
2 parents caf6840 + c5d0b12 commit 94294e9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

builtin/gc.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,7 @@ static int crontab_update_schedule(int run_maintenance, int fd, const char *cmd)
19091909
else if (!in_old_region)
19101910
fprintf(cron_in, "%s\n", line.buf);
19111911
}
1912+
strbuf_release(&line);
19121913

19131914
if (run_maintenance) {
19141915
struct strbuf line_format = STRBUF_INIT;
@@ -1971,8 +1972,10 @@ static int update_background_schedule(int enable)
19711972
cmd = sep + 1;
19721973
}
19731974

1974-
if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0)
1975-
return error(_("another process is scheduling background maintenance"));
1975+
if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
1976+
result = error(_("another process is scheduling background maintenance"));
1977+
goto cleanup;
1978+
}
19761979

19771980
if (!strcmp(scheduler, "launchctl"))
19781981
result = launchctl_update_schedule(enable, get_lock_file_fd(&lk), cmd);
@@ -1984,6 +1987,9 @@ static int update_background_schedule(int enable)
19841987
die("unknown background scheduler: %s", scheduler);
19851988

19861989
rollback_lock_file(&lk);
1990+
1991+
cleanup:
1992+
free(lock_path);
19871993
free(testing);
19881994
return result;
19891995
}

0 commit comments

Comments
 (0)