From 75abd2b92452782a9e6cee6ed5041339bd00c5bf Mon Sep 17 00:00:00 2001 From: schu Date: Thu, 11 Aug 2011 19:38:13 +0200 Subject: Free all used references in the source tree Since references are not owned by the repository anymore we have to free them manually now. Signed-off-by: schu --- src/commit.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/commit.c') diff --git a/src/commit.c b/src/commit.c index 1010fdc56..83bc9fc4c 100644 --- a/src/commit.c +++ b/src/commit.c @@ -145,8 +145,10 @@ int git_commit_create( error = git_reference_resolve(&target, head); if (error < GIT_SUCCESS) { - if (error != GIT_ENOTFOUND) + if (error != GIT_ENOTFOUND) { + git_reference_free(head); return git__rethrow(error, "Failed to create commit"); + } /* * The target of the reference was not found. This can happen * just after a repository has been initialized (the master @@ -154,10 +156,19 @@ int git_commit_create( * point to) or after an orphan checkout, so if the target * branch doesn't exist yet, create it and return. */ - return git_reference_create_oid(&head, repo, git_reference_target(head), oid, 1); + error = git_reference_create_oid(&target, repo, git_reference_target(head), oid, 1); + + git_reference_free(head); + if (error == GIT_SUCCESS) + git_reference_free(target); + + return error; } error = git_reference_set_oid(target, oid); + + git_reference_free(head); + git_reference_free(target); } if (error < GIT_SUCCESS) -- cgit v1.2.1