diff options
author | schu <schu-github@schulog.org> | 2011-08-11 19:38:13 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-11-06 03:15:26 +0100 |
commit | 75abd2b92452782a9e6cee6ed5041339bd00c5bf (patch) | |
tree | d2ef55289b8d10e1caa813a86fdebb1e00436489 /src/commit.c | |
parent | 4fd89fa0392967fabb905c7f4001cd4834f11dbd (diff) | |
download | libgit2-75abd2b92452782a9e6cee6ed5041339bd00c5bf.tar.gz |
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 <schu-github@schulog.org>
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 15 |
1 files changed, 13 insertions, 2 deletions
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) |