diff --git a/object.c b/object.c index 66cffaf6e5..97245fdea2 100644 --- a/object.c +++ b/object.c @@ -481,6 +481,9 @@ void raw_object_store_clear(struct raw_object_store *o) FREE_AND_NULL(o->objectdir); FREE_AND_NULL(o->alternate_db); + oidmap_free(o->replace_map, 1); + FREE_AND_NULL(o->replace_map); + free_alt_odbs(o); o->alt_odb_tail = NULL; diff --git a/refs.c b/refs.c index 64aadd14c9..2e4a42f459 100644 --- a/refs.c +++ b/refs.c @@ -1668,6 +1668,9 @@ struct ref_store *get_main_ref_store(struct repository *r) if (r->refs) return r->refs; + if (!r->gitdir) + BUG("attempting to get main_ref_store outside of repository"); + r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS); return r->refs; } diff --git a/replace-object.c b/replace-object.c index 246b98cd4f..801b5c1678 100644 --- a/replace-object.c +++ b/replace-object.c @@ -37,7 +37,7 @@ static void prepare_replace_object(struct repository *r) return; r->objects->replace_map = - xmalloc(sizeof(*the_repository->objects->replace_map)); + xmalloc(sizeof(*r->objects->replace_map)); oidmap_init(r->objects->replace_map, 0); for_each_replace_ref(r, register_replace_ref, NULL);