Skip to content

Commit 02f27d0

Browse files
committed
Merge branch 'sb/plug-misc-leaks'
Misc leak plugging. * sb/plug-misc-leaks: sequencer.c: plug mem leak in git_sequencer_config sequencer.c: plug leaks in do_pick_commit submodule--helper: plug mem leak in print_default_remote refs/packed-backend.c: close fd of empty file
2 parents 90fa1c5 + f40f3c1 commit 02f27d0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

builtin/submodule--helper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static char *get_default_remote(void)
5555

5656
static int print_default_remote(int argc, const char **argv, const char *prefix)
5757
{
58-
const char *remote;
58+
char *remote;
5959

6060
if (argc != 1)
6161
die(_("submodule--helper print-default-remote takes no arguments"));
@@ -64,6 +64,7 @@ static int print_default_remote(int argc, const char **argv, const char *prefix)
6464
if (remote)
6565
printf("%s\n", remote);
6666

67+
free(remote);
6768
return 0;
6869
}
6970

refs/packed-backend.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ static int load_contents(struct snapshot *snapshot)
499499
size = xsize_t(st.st_size);
500500

501501
if (!size) {
502+
close(fd);
502503
return 0;
503504
} else if (mmap_strategy == MMAP_NONE || size <= SMALL_FILE_SIZE) {
504505
snapshot->buf = xmalloc(size);

sequencer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
176176
warning(_("invalid commit message cleanup mode '%s'"),
177177
s);
178178

179+
free((char *)s);
179180
return status;
180181
}
181182

@@ -1774,7 +1775,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
17741775
res = do_recursive_merge(base, next, base_label, next_label,
17751776
&head, &msgbuf, opts);
17761777
if (res < 0)
1777-
return res;
1778+
goto leave;
1779+
17781780
res |= write_message(msgbuf.buf, msgbuf.len,
17791781
git_path_merge_msg(), 0);
17801782
} else {

0 commit comments

Comments
 (0)