diff options
| author | Sascha Cunz <Sascha@BabbelBox.org> | 2012-11-23 11:41:56 +0100 |
|---|---|---|
| committer | Sascha Cunz <Sascha@BabbelBox.org> | 2012-11-23 11:41:56 +0100 |
| commit | 9094d30b932ca4b47dba81e76011efe05455a44a (patch) | |
| tree | 117c53e9ad194d00274ad98e784318bd960c4053 /tests-clar/repo | |
| parent | 5cf1b4f094eb6f724b27aa01d4f0481de2e673af (diff) | |
| download | libgit2-9094d30b932ca4b47dba81e76011efe05455a44a.tar.gz | |
Reset all static variables to NULL in clar's __cleanup
Without this change, any failed assertion in the second (or a later) test
inside a test suite has a chance of double deleting memory, resulting in
a heap corruption. See #1096 for details.
This leaves alone the test cases where we "just" use cl_git_sandbox_init()
and cl_git_sandbox_cleanup(). These methods already take good care to not
double delete a repository.
Fixes #1096
Diffstat (limited to 'tests-clar/repo')
| -rw-r--r-- | tests-clar/repo/head.c | 2 | ||||
| -rw-r--r-- | tests-clar/repo/init.c | 2 | ||||
| -rw-r--r-- | tests-clar/repo/setters.c | 2 |
3 files changed, 5 insertions, 1 deletions
diff --git a/tests-clar/repo/head.c b/tests-clar/repo/head.c index 551e834f2..23d14d619 100644 --- a/tests-clar/repo/head.c +++ b/tests-clar/repo/head.c @@ -3,7 +3,7 @@ #include "repo_helpers.h" #include "posix.h" -git_repository *repo; +static git_repository *repo; void test_repo_head__initialize(void) { diff --git a/tests-clar/repo/init.c b/tests-clar/repo/init.c index f76e8bc3d..f29f54091 100644 --- a/tests-clar/repo/init.c +++ b/tests-clar/repo/init.c @@ -19,6 +19,8 @@ void test_repo_init__initialize(void) static void cleanup_repository(void *path) { git_repository_free(_repo); + _repo = NULL; + cl_fixture_cleanup((const char *)path); } diff --git a/tests-clar/repo/setters.c b/tests-clar/repo/setters.c index cd6e389ae..7e482dee1 100644 --- a/tests-clar/repo/setters.c +++ b/tests-clar/repo/setters.c @@ -17,6 +17,8 @@ void test_repo_setters__initialize(void) void test_repo_setters__cleanup(void) { git_repository_free(repo); + repo = NULL; + cl_fixture_cleanup("testrepo.git"); cl_fixture_cleanup("new_workdir"); } |
