aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--connected.c38
-rw-r--r--meson.build2
-rw-r--r--object-file.c2
-rw-r--r--pack-revindex.c4
5 files changed, 26 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 58fb895f4e..c619b5405b 100644
--- a/Makefile
+++ b/Makefile
@@ -1605,6 +1605,7 @@ BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
endif
ifneq ($(filter leak,$(SANITIZERS)),)
BASIC_CFLAGS += -O0
+NO_MMAP = CatchMapLeaks
SANITIZE_LEAK = YesCompiledWithIt
endif
ifneq ($(filter address,$(SANITIZERS)),)
diff --git a/connected.c b/connected.c
index 79403108dd..6718503649 100644
--- a/connected.c
+++ b/connected.c
@@ -45,20 +45,6 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
return err;
}
- if (transport && transport->smart_options &&
- transport->smart_options->self_contained_and_connected &&
- transport->pack_lockfiles.nr == 1 &&
- strip_suffix(transport->pack_lockfiles.items[0].string,
- ".keep", &base_len)) {
- struct strbuf idx_file = STRBUF_INIT;
- strbuf_add(&idx_file, transport->pack_lockfiles.items[0].string,
- base_len);
- strbuf_addstr(&idx_file, ".idx");
- new_pack = add_packed_git(the_repository, idx_file.buf,
- idx_file.len, 1);
- strbuf_release(&idx_file);
- }
-
if (repo_has_promisor_remote(the_repository)) {
/*
* For partial clones, we don't want to have to do a regular
@@ -90,7 +76,6 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
promisor_pack_found:
;
} while ((oid = fn(cb_data)) != NULL);
- free(new_pack);
return 0;
}
@@ -127,15 +112,27 @@ no_promisor_pack_found:
else
rev_list.no_stderr = opt->quiet;
- if (start_command(&rev_list)) {
- free(new_pack);
+ if (start_command(&rev_list))
return error(_("Could not run 'git rev-list'"));
- }
sigchain_push(SIGPIPE, SIG_IGN);
rev_list_in = xfdopen(rev_list.in, "w");
+ if (transport && transport->smart_options &&
+ transport->smart_options->self_contained_and_connected &&
+ transport->pack_lockfiles.nr == 1 &&
+ strip_suffix(transport->pack_lockfiles.items[0].string,
+ ".keep", &base_len)) {
+ struct strbuf idx_file = STRBUF_INIT;
+ strbuf_add(&idx_file, transport->pack_lockfiles.items[0].string,
+ base_len);
+ strbuf_addstr(&idx_file, ".idx");
+ new_pack = add_packed_git(the_repository, idx_file.buf,
+ idx_file.len, 1);
+ strbuf_release(&idx_file);
+ }
+
do {
/*
* If index-pack already checked that:
@@ -162,6 +159,9 @@ no_promisor_pack_found:
err = error_errno(_("failed to close rev-list's stdin"));
sigchain_pop(SIGPIPE);
- free(new_pack);
+ if (new_pack) {
+ close_pack(new_pack);
+ free(new_pack);
+ }
return finish_command(&rev_list) || err;
}
diff --git a/meson.build b/meson.build
index 1036eafc3c..9e9ba9b82b 100644
--- a/meson.build
+++ b/meson.build
@@ -1438,7 +1438,7 @@ else
'getpagesize' : [],
}
- if get_option('b_sanitize').contains('address')
+ if get_option('b_sanitize').contains('address') or get_option('b_sanitize').contains('leak')
libgit_c_args += '-DNO_MMAP'
libgit_sources += 'compat/mmap.c'
else
diff --git a/object-file.c b/object-file.c
index a3ff7f586c..c62e5496e0 100644
--- a/object-file.c
+++ b/object-file.c
@@ -2211,7 +2211,7 @@ int odb_source_loose_read_object_stream(struct odb_read_stream **out,
return 0;
error:
git_inflate_end(&st->z);
- munmap(st->mapped, st->mapsize);
+ munmap(mapped, mapsize);
free(st);
return -1;
}
diff --git a/pack-revindex.c b/pack-revindex.c
index 56cd803a67..1fe0afe899 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -277,6 +277,10 @@ int load_pack_revindex_from_disk(struct packed_git *p)
{
char *revindex_name;
int ret;
+
+ if (p->revindex_data)
+ return 0;
+
if (open_pack_index(p))
return -1;