summaryrefslogtreecommitdiff
path: root/src/submodule.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-03-26 16:06:21 -0700
committerRussell Belfer <rb@github.com>2014-03-26 16:06:21 -0700
commit380f864a10aeadd30bd88138906d4fab577221de (patch)
tree502536aa9a7480ed542f6d9d2f4bd6adc71bef82 /src/submodule.c
parent22df47cbc52107db25368cf0a09d63cc8dddafdb (diff)
downloadlibgit2-380f864a10aeadd30bd88138906d4fab577221de.tar.gz
Fix error when submodule path and name differ
When a submodule was inserted with a different path and name, the return value from khash greater than zero was allowed to propagate back out to the caller when it should really be zeroed. This led to a possible crash when reloading submodules if that was the first time that submodule data was loaded.
Diffstat (limited to 'src/submodule.c')
-rw-r--r--src/submodule.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/submodule.c b/src/submodule.c
index 54ffc6103..b07c9d917 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -1279,14 +1279,17 @@ static int submodule_load_from_config(
}
}
+ /* Found a alternate key for the submodule */
if (alternate) {
void *old_sm = NULL;
git_strmap_insert2(smcfg, alternate, sm, old_sm, error);
if (error < 0)
goto done;
- if (error >= 0)
- GIT_REFCOUNT_INC(sm); /* inserted under a new key */
+ if (error > 0)
+ error = 0;
+
+ GIT_REFCOUNT_INC(sm); /* increase refcount for new key */
/* if we replaced an old module under this key, release the old one */
if (old_sm && ((git_submodule *)old_sm) != sm) {