diff options
author | Russell Belfer <rb@github.com> | 2014-03-26 14:38:26 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-03-26 14:38:26 -0700 |
commit | 22df47cbc52107db25368cf0a09d63cc8dddafdb (patch) | |
tree | 78c4053629bc5b34abc0626f3d2075ddddcc9837 /src/submodule.c | |
parent | f4afcaa0d50bece4a784ce680d92e5c0d1c67785 (diff) | |
download | libgit2-22df47cbc52107db25368cf0a09d63cc8dddafdb.tar.gz |
Fix segfault if gitmodules is invalid
The reload_all call could end up dereferencing a NULL pointer if
there was an error while attempting to load the submodules config
data (i.e. invalid content in the gitmodules file). This fixes it.
Diffstat (limited to 'src/submodule.c')
-rw-r--r-- | src/submodule.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/submodule.c b/src/submodule.c index 769b092a0..54ffc6103 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -156,7 +156,7 @@ int git_submodule_lookup( if (git_buf_joinpath(&path, git_repository_workdir(repo), name) < 0) return -1; - if (git_path_contains_dir(&path, DOT_GIT)) + if (git_path_contains(&path, DOT_GIT)) error = GIT_EEXISTS; git_buf_free(&path); @@ -846,7 +846,8 @@ int git_submodule_reload_all(git_repository *repo, int force) if (repo->submodules) git_strmap_foreach_value(repo->submodules, sm, { sm->flags = 0; }); - error = load_submodule_config(repo, true); + if ((error = load_submodule_config(repo, true)) < 0) + return error; git_strmap_foreach_value(repo->submodules, sm, { git_strmap *cache = repo->submodules; |