Commit e1859ea184a0a440b83d6c9cdb7827031b037e92

Vicent Martí 2013-01-27T13:15:48

Merge pull request #1283 from lznuaa/master Fix local repository clone failure

diff --git a/src/transports/local.c b/src/transports/local.c
index c6e7984..44431d5 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -318,12 +318,15 @@ static int local_download_pack(
 
 		if (!git_object_lookup((git_object**)&commit, t->repo, &oid, GIT_OBJ_COMMIT)) {
 			const git_oid *tree_oid = git_commit_tree_id(commit);
-			git_commit_free(commit);
 
 			/* Add the commit and its tree */
 			if ((error = git_packbuilder_insert(pack, &oid, NULL)) < 0 ||
-				 (error = git_packbuilder_insert_tree(pack, tree_oid)) < 0)
+				 (error = git_packbuilder_insert_tree(pack, tree_oid)) < 0) {
+				git_commit_free(commit);
 				goto cleanup;
+			}
+
+			git_commit_free(commit);
 		}
 	}