Commit 36a5b557f146affcc627e6f762b2ab722e2796ce

Etienne Samson 2018-06-19T20:18:26

submodule: don't leak memory when failing to insert the names Reported by Coverity, CID 1393237

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/submodule.c b/src/submodule.c
index d0c7d04..3cbddfa 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -260,7 +260,8 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
 		git_strmap_insert(names, entry->value, git_buf_detach(&buf), &rval);
 		if (rval < 0) {
 			giterr_set(GITERR_NOMEMORY, "error inserting submodule into hash table");
-			return -1;
+			error = -1;
+			goto out;
 		}
 	}
 	if (error == GIT_ITEROVER)