Skip to content

Commit cabe16d

Browse files
committed
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.
1 parent f1ad004 commit cabe16d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tests/index/filemodes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ void test_index_filemodes__frombuffer_requires_files(void)
264264
const git_index_entry *ret_entry;
265265
const char *content = "hey there\n";
266266

267+
memset(&new_entry, 0, sizeof(new_entry));
267268
cl_git_pass(git_repository_index(&index, g_repo));
268269

269270
/* regular blob */

0 commit comments

Comments
 (0)