Code

git send-email: avoid leaking directory file descriptors.
[git.git] / remote.c
index f61a3ab399aa6960fb8eba050321cea4a3b05344..7688f3b04d197007bce64a2bcc54c0b62c0b5922 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -342,13 +342,14 @@ static int handle_config(const char *key, const char *value, void *cb)
        if (prefixcmp(key,  "remote."))
                return 0;
        name = key + 7;
+       if (*name == '/') {
+               warning("Config remote shorthand cannot begin with '/': %s",
+                       name);
+               return 0;
+       }
        subkey = strrchr(name, '.');
        if (!subkey)
                return error("Config with no key for remote %s", name);
-       if (*subkey == '/') {
-               warning("Config remote shorthand cannot begin with '/': %s", name);
-               return 0;
-       }
        remote = make_remote(name, subkey - name);
        if (!strcmp(subkey, ".mirror"))
                remote->mirror = git_config_bool(key, value);
@@ -579,8 +580,7 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
        struct refspec *refspec;
 
        refspec = parse_refspec_internal(1, fetch_refspec, 1, 1);
-       if (refspec)
-               free(refspec);
+       free(refspec);
        return !!refspec;
 }