Merge branch 'sb/plug-misc-leaks'
authorJunio C Hamano <gitster@pobox.com>
Mon, 25 Jun 2018 20:22:41 +0000 (13:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Jun 2018 20:22:41 +0000 (13:22 -0700)
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

builtin/submodule--helper.c
refs/packed-backend.c
sequencer.c
index c9c2f0e10264a365eaead2beadd07e3e1a36bd8b..20ae9191ca376841ca2540502d85a3dc150d3417 100644 (file)
@@ -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;
 }
 
index cec3fb9e00f78c1e0be9f24bd07aa756d56afc00..d447a731da0932e60c918030c7cd07a1843dfd35 100644 (file)
@@ -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);
index ee1f7b2df74572b1bff71436fa7961f47ac25378..5354d4d51e62a31d5254334851bce1b5bb5558a9 100644 (file)
@@ -176,6 +176,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;
        }
 
@@ -1774,7 +1775,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 {