summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-02-19 10:18:59 +0000
committerPatrick Steinhardt <ps@pks.im>2018-02-19 10:18:59 +0000
commitcabe16df0d7fc3b6fa2242064a6fa34282a102f4 (patch)
treec0ea43e2793c34d6dfbd5662b851c596b28085b7
parentf1ad004ccb880b13714aefa00e2b62f48803d619 (diff)
downloadlibgit2-cabe16df0d7fc3b6fa2242064a6fa34282a102f4.tar.gz
tests: index::filemodes: fix use of uninitialized memory
The new index entry structure was not being initialized to all-zeroes. As that structure is used to add a new entry to the current index, and the hashing algorithm of the index making use of the uninitialized flags to calculate the state, we might miscompute the hash of the entry and add it at the wrong position. Later lookups would then fail. Initialize the structure with `memset` to fix the test breaking on some platforms.
-rw-r--r--tests/index/filemodes.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/index/filemodes.c b/tests/index/filemodes.c
index f53414df5..2693b1312 100644
--- a/tests/index/filemodes.c
+++ b/tests/index/filemodes.c
@@ -264,6 +264,7 @@ void test_index_filemodes__frombuffer_requires_files(void)
const git_index_entry *ret_entry;
const char *content = "hey there\n";
+ memset(&new_entry, 0, sizeof(new_entry));
cl_git_pass(git_repository_index(&index, g_repo));
/* regular blob */