diff options
author | Carlos MartÃn Nieto <cmn@dwim.me> | 2018-05-24 20:28:36 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-06-01 13:44:32 +0200 |
commit | 95a0ab897373fc363d2f8aa09d81227b26f8ad99 (patch) | |
tree | 468de7385d8c41ccfcab0529c2d30684b0c2de0f | |
parent | d1aaa5e24c342d4afb72365cd5346a3f55320aff (diff) | |
download | libgit2-95a0ab897373fc363d2f8aa09d81227b26f8ad99.tar.gz |
submodule: plug leaks from the escape detection
-rw-r--r-- | src/submodule.c | 13 | ||||
-rw-r--r-- | tests/submodule/escape.c | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/submodule.c b/src/submodule.c index b1116eeb2..96c8e6675 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -186,10 +186,13 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi fdot = strchr(entry->name, '.'); ldot = strrchr(entry->name, '.'); + git_buf_clear(&buf); git_buf_put(&buf, fdot + 1, ldot - fdot - 1); isvalid = git_submodule_name_is_valid(repo, buf.ptr, 0); - if (isvalid < 0) - return isvalid; + if (isvalid < 0) { + error = isvalid; + goto out; + } if (!isvalid) continue; @@ -199,9 +202,13 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi return -1; } } + if (error == GIT_ITEROVER) + error = 0; +out: + git_buf_free(&buf); git_config_iterator_free(iter); - return 0; + return error; } int git_submodule_lookup( diff --git a/tests/submodule/escape.c b/tests/submodule/escape.c index 0a3c4a3b8..f5c3cd4cd 100644 --- a/tests/submodule/escape.c +++ b/tests/submodule/escape.c @@ -43,6 +43,7 @@ void test_submodule_escape__from_gitdir(void) "[submodule \"" EVIL_SM_NAME "\"]\n" " path = testrepo\n" " url = ../testrepo.git\n"); + git_buf_free(&buf); /* Find it all the different ways we know about it */ foundit = 0; @@ -76,6 +77,7 @@ void test_submodule_escape__from_gitdir_windows(void) "[submodule \"" EVIL_SM_NAME_WINDOWS "\"]\n" " path = testrepo\n" " url = ../testrepo.git\n"); + git_buf_free(&buf); /* Find it all the different ways we know about it */ foundit = 0; |