Commit 7cdad6c77425348364d9c10582b1b779dd7c1ade

Sascha Cunz 2012-11-28T12:43:12

Fix uninitialized variable clang-SVN HEAD kindly provided my the info, that sm_repo maybe uninitialized when we want to free it (If the expression in line 358 or 359/360 evaluate to true, we jump to "cleanup", where we'd use sm_repo uninitialized).

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/submodule.c b/src/submodule.c
index b6e5c96..15158f0 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -341,7 +341,7 @@ int git_submodule_add_finalize(git_submodule *sm)
 int git_submodule_add_to_index(git_submodule *sm, int write_index)
 {
 	int error;
-	git_repository *repo, *sm_repo;
+	git_repository *repo, *sm_repo = NULL;
 	git_index *index;
 	git_buf path = GIT_BUF_INIT;
 	git_commit *head;