diff options
author | Carlos Martín Nieto <cmn@elego.de> | 2011-04-13 17:44:08 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@elego.de> | 2011-04-13 21:50:11 +0200 |
commit | 2fe3692c2315981e00bb09fd616601d0720ec1ac (patch) | |
tree | a3a7d153a24129090aef481ca03180f7f261d47c /tests/t04-commit.c | |
parent | fdd0cc9e8948bb65c9a461c58e5094a3613bd975 (diff) | |
download | libgit2-2fe3692c2315981e00bb09fd616601d0720ec1ac.tar.gz |
tests: don't leak objects
If we don't create any leaks in the tests, we can use them to search
for leaks in the implementation.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'tests/t04-commit.c')
-rw-r--r-- | tests/t04-commit.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/t04-commit.c b/tests/t04-commit.c index bcc0417c8..3e02df996 100644 --- a/tests/t04-commit.c +++ b/tests/t04-commit.c @@ -368,7 +368,7 @@ BEGIN_TEST(details0, "query the details on a parsed commit") const char *message, *message_short; git_time_t commit_time; unsigned int parents, p; - git_commit *parent; + git_commit *parent = NULL, *old_parent = NULL; git_oid_mkstr(&id, commit_ids[i]); @@ -390,11 +390,19 @@ BEGIN_TEST(details0, "query the details on a parsed commit") must_be_true(commit_time > 0); must_be_true(parents <= 2); for (p = 0;p < parents;p++) { + if (old_parent != NULL) + git_commit_close(old_parent); + + old_parent = parent; must_pass(git_commit_parent(&parent, commit, p)); must_be_true(parent != NULL); must_be_true(git_commit_author(parent) != NULL); // is it really a commit? } + git_commit_close(old_parent); + git_commit_close(parent); + must_fail(git_commit_parent(&parent, commit, parents)); + git_commit_close(commit); } git_repository_free(repo); @@ -462,6 +470,7 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk") must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit)); + git_commit_close(commit); git_repository_free(repo); END_TEST |