diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-09-24 13:20:48 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-09-24 13:20:48 +0200 |
| commit | 588e28ebfd16dc030be3226e4bc2107cdbad67b4 (patch) | |
| tree | 5af07ac659adc4fed7f0969ac89d72981071cfb6 /src | |
| parent | 27187344bb33060ffc4208f7b7f2412fce2b7110 (diff) | |
| parent | ab8f2c669a2a0bb66d5473f83ecb47ad805a7078 (diff) | |
| download | libgit2-588e28ebfd16dc030be3226e4bc2107cdbad67b4.tar.gz | |
Merge pull request #3437 from libgit2/cmn/plug-sm
submodule: plug a few leaks
Diffstat (limited to 'src')
| -rw-r--r-- | src/submodule.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/submodule.c b/src/submodule.c index 1d73dc24e..998ef91fd 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -170,7 +170,7 @@ static int name_from_path(git_buf *out, git_config *cfg, const char *path) git_buf_clear(out); git_buf_put(out, fdot + 1, ldot - fdot - 1); - return 0; + goto cleanup; } if (error == GIT_ITEROVER) { @@ -178,6 +178,8 @@ static int name_from_path(git_buf *out, git_config *cfg, const char *path) error = GIT_ENOTFOUND; } +cleanup: + git_config_iterator_free(iter); return error; } @@ -1701,7 +1703,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) GITERR_CHECK_ALLOC(sm->path); } } else if (error != GIT_ENOTFOUND) { - return error; + goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "url")) == 0) { @@ -1709,7 +1711,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) sm->url = git__strdup(value); GITERR_CHECK_ALLOC(sm->url); } else if (error != GIT_ENOTFOUND) { - return error; + goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "branch")) == 0) { @@ -1717,40 +1719,44 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) sm->branch = git__strdup(value); GITERR_CHECK_ALLOC(sm->branch); } else if (error != GIT_ENOTFOUND) { - return error; + goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "update")) == 0) { in_config = 1; if ((error = git_submodule_parse_update(&sm->update, value)) < 0) - return error; + goto cleanup; sm->update_default = sm->update; } else if (error != GIT_ENOTFOUND) { - return error; + goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "fetchRecurseSubmodules")) == 0) { in_config = 1; if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) - return error; + goto cleanup; sm->fetch_recurse_default = sm->fetch_recurse; } else if (error != GIT_ENOTFOUND) { - return error; + goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "ignore")) == 0) { in_config = 1; if ((error = git_submodule_parse_ignore(&sm->ignore, value)) < 0) - return error; + goto cleanup; sm->ignore_default = sm->ignore; } else if (error != GIT_ENOTFOUND) { - return error; + goto cleanup; } if (in_config) sm->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; - return 0; + error = 0; + +cleanup: + git_buf_free(&key); + return error; } static int submodule_load_each(const git_config_entry *entry, void *payload) @@ -1784,8 +1790,10 @@ static int submodule_load_each(const git_config_entry *entry, void *payload) * already inserted, we've already loaded it, so we skip. */ pos = git_strmap_lookup_index(map, name.ptr); - if (git_strmap_valid_index(map, pos)) - return 0; + if (git_strmap_valid_index(map, pos)) { + error = 0; + goto done; + } if ((error = submodule_alloc(&sm, data->repo, name.ptr)) < 0) goto done; |
