Skip to content

Commit 1dd4e74

Browse files
committed
Merge branch 'js/fsmonitor-unpack-fix'
The data structure used by fsmonitor interface was not properly duplicated during an in-core merge, leading to use-after-free etc. * js/fsmonitor-unpack-fix: fsmonitor: do not forget to release the token in `discard_index()` fsmonitor: fix memory corruption in some corner cases
2 parents 35381b1 + 4abc578 commit 1dd4e74

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

read-cache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,7 @@ int discard_index(struct index_state *istate)
23732373
cache_tree_free(&(istate->cache_tree));
23742374
istate->initialized = 0;
23752375
istate->fsmonitor_has_run_once = 0;
2376+
FREE_AND_NULL(istate->fsmonitor_last_update);
23762377
FREE_AND_NULL(istate->cache);
23772378
istate->cache_alloc = 0;
23782379
discard_split_index(istate);

unpack-trees.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,8 +1612,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
16121612
o->merge_size = len;
16131613
mark_all_ce_unused(o->src_index);
16141614

1615-
if (o->src_index->fsmonitor_last_update)
1616-
o->result.fsmonitor_last_update = o->src_index->fsmonitor_last_update;
1615+
o->result.fsmonitor_last_update =
1616+
xstrdup_or_null(o->src_index->fsmonitor_last_update);
16171617

16181618
/*
16191619
* Sparse checkout loop #1: set NEW_SKIP_WORKTREE on existing entries

0 commit comments

Comments
 (0)