]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: fix leak of haves/wants object lists
authorJeff King <peff@peff.net>
Thu, 13 Feb 2020 02:16:33 +0000 (21:16 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Feb 2020 17:08:58 +0000 (09:08 -0800)
When we do a bitmap-aware revision traversal, we create an object_list
for each of the "haves" and "wants" tips. After creating the result
bitmaps these are no longer needed or used, but we never free the list
memory.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object.c
object.h
pack-bitmap.c

index 142ef69399a2fd81c36d81291c573295715b48b8..4d11949b38a93f405c385c8e137dbb891af479f7 100644 (file)
--- a/object.c
+++ b/object.c
@@ -307,6 +307,15 @@ int object_list_contains(struct object_list *list, struct object *obj)
        return 0;
 }
 
+void object_list_free(struct object_list **list)
+{
+       while (*list) {
+               struct object_list *p = *list;
+               *list = p->next;
+               free(p);
+       }
+}
+
 /*
  * A zero-length string to which object_array_entry::name can be
  * initialized without requiring a malloc/free.
index 25f5ab3d54a8b1111b8bb4ce0e4b024894ce8e54..2dbabfca0ab8185f52cca6d3b7c69658e838ae49 100644 (file)
--- a/object.h
+++ b/object.h
@@ -151,6 +151,8 @@ struct object_list *object_list_insert(struct object *item,
 
 int object_list_contains(struct object_list *list, struct object *obj);
 
+void object_list_free(struct object_list **list);
+
 /* Object array handling .. */
 void add_object_array(struct object *obj, const char *name, struct object_array *array);
 void add_object_array_with_path(struct object *obj, const char *name, struct object_array *array, unsigned mode, const char *path);
index 9ca356ee29b1b21dadb1060999aa66a1d1586f48..6c06099dc782efd66f3122c6f146665666d7aad0 100644 (file)
@@ -787,10 +787,15 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
        bitmap_git->result = wants_bitmap;
        bitmap_git->haves = haves_bitmap;
 
+       object_list_free(&wants);
+       object_list_free(&haves);
+
        return bitmap_git;
 
 cleanup:
        free_bitmap_index(bitmap_git);
+       object_list_free(&wants);
+       object_list_free(&haves);
        return NULL;
 }