Skip to content

Commit 322ee20

Browse files
jeffhostetlerderrickstolee
authored andcommitted
sparse-index: fix crash in status
Copy the `index_state->dir_hash` back to the real istate after expanding a sparse index. A crash was observed in `git status` during some hashmap lookups with corrupted hashmap entries. During an index expansion, new cache-entries are added to the `index_state->name_hash` and the `dir_hash` in a temporary `index_state` variable `full`. However, only the `name_hash` hashmap from this temp variable was copied back into the real `istate` variable. The original copy of the `dir_hash` was incorrectly preserved. If the table in the `full->dir_hash` hashmap were realloced, the stale version (in `istate`) would be corrupted. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 8c587d7 commit 322ee20

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

sparse-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ void ensure_full_index(struct index_state *istate)
283283

284284
/* Copy back into original index. */
285285
memcpy(&istate->name_hash, &full->name_hash, sizeof(full->name_hash));
286+
memcpy(&istate->dir_hash, &full->dir_hash, sizeof(full->dir_hash));
286287
istate->sparse_index = 0;
287288
free(istate->cache);
288289
istate->cache = full->cache;

0 commit comments

Comments
 (0)