remote: Fix bogus make_branch() call in configuration reader.
authorJunio C Hamano <gitster@pobox.com>
Sat, 15 Dec 2007 04:34:56 +0000 (20:34 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 15 Dec 2007 04:34:56 +0000 (20:34 -0800)
The configuration reader to enumerate branches that have configuration
data were not careful enough and failed to skip "branch.<variable>"
entries (e.g. branch.autosetupmerge). This resulted in bogus attempt to
allocate huge memory.

Noticed by David Miller.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c
index 3fb0f99b29e7ffd927abf166cfa004c1937aaf60..0e006804ef3cc190fa286c85e2de034a33791886 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -220,11 +220,11 @@ static int handle_config(const char *key, const char *value)
        if (!prefixcmp(key, "branch.")) {
                name = key + 7;
                subkey = strrchr(name, '.');
-               branch = make_branch(name, subkey - name);
                if (!subkey)
                        return 0;
                if (!value)
                        return 0;
+               branch = make_branch(name, subkey - name);
                if (!strcmp(subkey, ".remote")) {
                        branch->remote_name = xstrdup(value);
                        if (branch == current_branch)