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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Nov 5, 2024 at 07:17 UTC
1f5ff83eab03773692fe6f7bab7f10ad82ab031b
1 file changed
+5
-2
sparse-index.c
+5
-2
@@ -2,6 +2,7 @@
2
3
#include "git-compat-util.h"
4
#include "environment.h"
5
+#include "ewah/ewok.h"
6
#include "gettext.h"
7
#include "name-hash.h"
8
#include "read-cache-ll.h"
@@ -242,7 +243,8 @@ int convert_to_sparse(struct index_state *istate, int flags)
243
cache_tree_update(istate, 0);
244
245
istate->fsmonitor_has_run_once = 0;
245
- FREE_AND_NULL(istate->fsmonitor_dirty);
246
+ ewah_free(istate->fsmonitor_dirty);
247
+ istate->fsmonitor_dirty = NULL;
248
FREE_AND_NULL(istate->fsmonitor_last_update);
249
250
istate->sparse_index = INDEX_COLLAPSED;
@@ -438,7 +440,8 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
440
istate->cache_nr = full->cache_nr;
441
istate->cache_alloc = full->cache_alloc;
442
istate->fsmonitor_has_run_once = 0;
441
- FREE_AND_NULL(istate->fsmonitor_dirty);
443
+ ewah_free(istate->fsmonitor_dirty);
444
+ istate->fsmonitor_dirty = NULL;
445
FREE_AND_NULL(istate->fsmonitor_last_update);
446
447
strbuf_release(&base);