diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2011-11-17 15:10:27 -0800 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-11-22 01:53:56 +0100 |
| commit | b762e576c6d0118664320f50be2e5810dbed4c15 (patch) | |
| tree | 2c244a57ca5167386856c573336093744464daa6 /tests | |
| parent | 1d09a1c88ddde32bf9b6b5ab6a9feab2ecdaa6ff (diff) | |
| download | libgit2-b762e576c6d0118664320f50be2e5810dbed4c15.tar.gz | |
filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanups
Update all stack allocations of git_filebuf to use GIT_FILEBUF_INIT
and make git_filebuf_open and git_filebuf_cleanup safe to be called
multiple times on the same buffer.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/t00-core.c | 6 | ||||
| -rw-r--r-- | tests/t06-index.c | 2 | ||||
| -rw-r--r-- | tests/t15-config.c | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/tests/t00-core.c b/tests/t00-core.c index 94824b43..16a5c6f9 100644 --- a/tests/t00-core.c +++ b/tests/t00-core.c @@ -462,7 +462,7 @@ BEGIN_TEST(dirent4, "make sure that strange looking filenames ('..c') are traver END_TEST BEGIN_TEST(filebuf0, "make sure git_filebuf_open doesn't delete an existing lock") - git_filebuf file; + git_filebuf file = GIT_FILEBUF_INIT; int fd; char test[] = "test", testlock[] = "test.lock"; @@ -475,7 +475,7 @@ BEGIN_TEST(filebuf0, "make sure git_filebuf_open doesn't delete an existing lock END_TEST BEGIN_TEST(filebuf1, "make sure GIT_FILEBUF_APPEND works as expected") - git_filebuf file; + git_filebuf file = GIT_FILEBUF_INIT; int fd; char test[] = "test"; @@ -492,7 +492,7 @@ BEGIN_TEST(filebuf1, "make sure GIT_FILEBUF_APPEND works as expected") END_TEST BEGIN_TEST(filebuf2, "make sure git_filebuf_write writes large buffer correctly") - git_filebuf file; + git_filebuf file = GIT_FILEBUF_INIT; char test[] = "test"; unsigned char buf[4096 * 4]; /* 2 * WRITE_BUFFER_SIZE */ diff --git a/tests/t06-index.c b/tests/t06-index.c index 44562d00..7b0f0512 100644 --- a/tests/t06-index.c +++ b/tests/t06-index.c @@ -163,7 +163,7 @@ END_TEST BEGIN_TEST(add0, "add a new file to the index") git_index *index; - git_filebuf file; + git_filebuf file = GIT_FILEBUF_INIT; git_repository *repo; git_index_entry *entry; git_oid id1; diff --git a/tests/t15-config.c b/tests/t15-config.c index a97f8206..9f0deb3e 100644 --- a/tests/t15-config.c +++ b/tests/t15-config.c @@ -306,7 +306,7 @@ END_TEST BEGIN_TEST(config16, "add a variable in a new section") git_config *cfg; int32_t i; - git_filebuf buf; + git_filebuf buf = GIT_FILEBUF_INIT; /* By freeing the config, we make sure we flush the values */ must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config10")); |
