Fix fail clone local repository because can't found object

avoid use object which is already free

Signed-off-by: Frank Li <lznuaa@gmail.com>
This commit is contained in:
Frank Li 2013-01-27 13:36:37 +08:00
parent aa3bf89df2
commit 88183c1988

View File

@ -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);
}
}