name-hash.c: always initialize dir_next pointer
PATCH 1/1 name-hash.c: always initialize dir_next pointer
Test t2021-checkout-overwrite.sh reveals a segfault in 'git add' on a case-insensitive file system when git is compiled with XMALLOC_POISON defined. The reason is that 2548183b (fix phantom untracked files when core.ignorecase is set) added a new member dir_next to struct cache_entry, but forgot to initialize it in all cases.
---
You can also insert git config core.ignorecase true before the first test script in t2021 to see the segfault.
I actually found the crash with an MSVC debug build, which has something like XMALLOC_POISON built-in.
name-hash.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
name-hash.c +1 -1
@@ -74,7 +74,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)if (ce->ce_flags &CE_HASHED )return ; ce->ce_flags |=CE_HASHED ; - ce->next =NULL ; + ce->next = ce->dir_next =NULL ; hash =hash_name (ce->name,ce_namelen (ce)); pos =insert_hash (hash, ce, &istate->name_hash);if (pos) {
Signature · 1 line
1.7.7.1.586.ga0958b
Thanks.
Quoted 10 lines · Johannes Sixt
Test
t2021-checkout-overwrite.shreveals a segfault in 'git add' on a case-insensitive file system when git is compiled withXMALLOC_POISONdefined. The reason is that2548183b(fix phantom untracked files when core.ignorecase is set) added a new memberdir_nextto structcache_entry, but forgot to initialize it in all cases.Signed-off-by Johannes Sixt <[email protected]>---
You can also insert git config core.ignorecase true before the first test script in t2021 to see the segfault.
Yikes, thanks.
-Peff