Skip to content

Commit 1f5ff83

Browse files
pks-tgitster
authored andcommitted
sparse-index: correctly free EWAH contents
While we free the `fsmonitor_dirty` member of `struct index_state`, we do not free the contents of that EWAH. Do so by using `ewah_free()` instead of `FREE_AND_NULL()`. This leak is exposed by t7519, but plugging it alone does not make the test suite pass. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4ba54d commit 1f5ff83

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sparse-index.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "git-compat-util.h"
44
#include "environment.h"
5+
#include "ewah/ewok.h"
56
#include "gettext.h"
67
#include "name-hash.h"
78
#include "read-cache-ll.h"
@@ -242,7 +243,8 @@ int convert_to_sparse(struct index_state *istate, int flags)
242243
cache_tree_update(istate, 0);
243244

244245
istate->fsmonitor_has_run_once = 0;
245-
FREE_AND_NULL(istate->fsmonitor_dirty);
246+
ewah_free(istate->fsmonitor_dirty);
247+
istate->fsmonitor_dirty = NULL;
246248
FREE_AND_NULL(istate->fsmonitor_last_update);
247249

248250
istate->sparse_index = INDEX_COLLAPSED;
@@ -438,7 +440,8 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
438440
istate->cache_nr = full->cache_nr;
439441
istate->cache_alloc = full->cache_alloc;
440442
istate->fsmonitor_has_run_once = 0;
441-
FREE_AND_NULL(istate->fsmonitor_dirty);
443+
ewah_free(istate->fsmonitor_dirty);
444+
istate->fsmonitor_dirty = NULL;
442445
FREE_AND_NULL(istate->fsmonitor_last_update);
443446

444447
strbuf_release(&base);

0 commit comments

Comments
 (0)