summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAshok P. Nadkarni <apnmbx-wits@yahoo.com>2022-02-14 13:57:07 +0530
committerAshok P. Nadkarni <apnmbx-wits@yahoo.com>2022-02-14 13:57:07 +0530
commitaab7c0babc3f0ad7c548847237e85f00ef82fe6b (patch)
tree6e09e7a05c330cb87b459c9f1c8b6c74d7a854ac /examples
parentc8450561d4065d13ad05d8f2269f65ceb810d1e9 (diff)
downloadlibgit2-aab7c0babc3f0ad7c548847237e85f00ef82fe6b.tar.gz
Free parent and ref in lg2_commit before returning.
Diffstat (limited to 'examples')
-rw-r--r--examples/commit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/commit.c b/examples/commit.c
index cd9782de1..aedc1af7e 100644
--- a/examples/commit.c
+++ b/examples/commit.c
@@ -26,7 +26,7 @@
* This does have:
*
* - Example of performing a git commit with a comment
- *
+ *
*/
int lg2_commit(git_repository *repo, int argc, char **argv)
{
@@ -36,10 +36,10 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
git_oid commit_oid,tree_oid;
git_tree *tree;
- git_index *index;
+ git_index *index;
git_object *parent = NULL;
git_reference *ref = NULL;
- git_signature *signature;
+ git_signature *signature;
/* Validate args */
if (argc < 3 || strcmp(opt, "-m") != 0) {
@@ -62,9 +62,9 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
check_lg2(git_index_write(index), "Could not write index", NULL);;
check_lg2(git_tree_lookup(&tree, repo, &tree_oid), "Error looking up tree", NULL);
-
+
check_lg2(git_signature_default(&signature, repo), "Error creating signature", NULL);
-
+
check_lg2(git_commit_create_v(
&commit_oid,
repo,
@@ -78,7 +78,9 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
git_index_free(index);
git_signature_free(signature);
- git_tree_free(tree);
+ git_tree_free(tree);
+ git_object_free(parent);
+ git_reference_free(ref);
return error;
}