From 09427e8366003ce3d99b0b5a84e42416cef35696 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 30 May 2018 10:03:00 -0700 Subject: [PATCH 1/4] refs/packed-backend.c: close fd of empty file Signed-off-by: Stefan Beller Acked-by: Michael Haggerty Signed-off-by: Junio C Hamano --- refs/packed-backend.c | 1 + 1 file changed, 1 insertion(+) diff --git a/refs/packed-backend.c b/refs/packed-backend.c index cec3fb9e00..d447a731da 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -499,6 +499,7 @@ static int load_contents(struct snapshot *snapshot) size = xsize_t(st.st_size); if (!size) { + close(fd); return 0; } else if (mmap_strategy == MMAP_NONE || size <= SMALL_FILE_SIZE) { snapshot->buf = xmalloc(size); From e6be8e2f9f87fbd6a4f58ac3cda4558563833088 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 30 May 2018 10:03:02 -0700 Subject: [PATCH 2/4] submodule--helper: plug mem leak in print_default_remote Signed-off-by: Stefan Beller Acked-by: Johannes Schindelin [jc: no need for remote to be const char *] Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index bd250ca216..7a752dbf9d 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -55,7 +55,7 @@ static char *get_default_remote(void) static int print_default_remote(int argc, const char **argv, const char *prefix) { - const char *remote; + char *remote; if (argc != 1) 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) if (remote) printf("%s\n", remote); + free(remote); return 0; } From 19517fb964f81c1bd3ddd006e0fc0119167d9cb2 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Fri, 1 Jun 2018 13:01:45 -0700 Subject: [PATCH 3/4] sequencer.c: plug leaks in do_pick_commit Going to leave, we additionally free the author and commit message and make sure to call update_abort_safety_file(). Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- sequencer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sequencer.c b/sequencer.c index 72b4d8ecae..ae6f2c27ec 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1772,7 +1772,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, res = do_recursive_merge(base, next, base_label, next_label, &head, &msgbuf, opts); if (res < 0) - return res; + goto leave; + res |= write_message(msgbuf.buf, msgbuf.len, git_path_merge_msg(), 0); } else { From f40f3c16cd3b0b5e696e62c08c84c8f527eaaf0e Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Fri, 1 Jun 2018 13:01:46 -0700 Subject: [PATCH 4/4] sequencer.c: plug mem leak in git_sequencer_config Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sequencer.c b/sequencer.c index ae6f2c27ec..9bdfd26a4b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -174,6 +174,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb) warning(_("invalid commit message cleanup mode '%s'"), s); + free((char *)s); return status; }