Commit 95a0ab89 by Carlos Martín Nieto Committed by Patrick Steinhardt

submodule: plug leaks from the escape detection

parent d1aaa5e2
...@@ -186,10 +186,13 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi ...@@ -186,10 +186,13 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi
fdot = strchr(entry->name, '.'); fdot = strchr(entry->name, '.');
ldot = strrchr(entry->name, '.'); ldot = strrchr(entry->name, '.');
git_buf_clear(&buf);
git_buf_put(&buf, fdot + 1, ldot - fdot - 1); git_buf_put(&buf, fdot + 1, ldot - fdot - 1);
isvalid = git_submodule_name_is_valid(repo, buf.ptr, 0); isvalid = git_submodule_name_is_valid(repo, buf.ptr, 0);
if (isvalid < 0) if (isvalid < 0) {
return isvalid; error = isvalid;
goto out;
}
if (!isvalid) if (!isvalid)
continue; continue;
...@@ -199,9 +202,13 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi ...@@ -199,9 +202,13 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi
return -1; return -1;
} }
} }
if (error == GIT_ITEROVER)
error = 0;
out:
git_buf_free(&buf);
git_config_iterator_free(iter); git_config_iterator_free(iter);
return 0; return error;
} }
int git_submodule_lookup( int git_submodule_lookup(
......
...@@ -43,6 +43,7 @@ void test_submodule_escape__from_gitdir(void) ...@@ -43,6 +43,7 @@ void test_submodule_escape__from_gitdir(void)
"[submodule \"" EVIL_SM_NAME "\"]\n" "[submodule \"" EVIL_SM_NAME "\"]\n"
" path = testrepo\n" " path = testrepo\n"
" url = ../testrepo.git\n"); " url = ../testrepo.git\n");
git_buf_free(&buf);
/* Find it all the different ways we know about it */ /* Find it all the different ways we know about it */
foundit = 0; foundit = 0;
...@@ -76,6 +77,7 @@ void test_submodule_escape__from_gitdir_windows(void) ...@@ -76,6 +77,7 @@ void test_submodule_escape__from_gitdir_windows(void)
"[submodule \"" EVIL_SM_NAME_WINDOWS "\"]\n" "[submodule \"" EVIL_SM_NAME_WINDOWS "\"]\n"
" path = testrepo\n" " path = testrepo\n"
" url = ../testrepo.git\n"); " url = ../testrepo.git\n");
git_buf_free(&buf);
/* Find it all the different ways we know about it */ /* Find it all the different ways we know about it */
foundit = 0; foundit = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment