Skip to content

Commit 92e1eb4

Browse files
peffgitster
authored andcommitted
http-push: clean up objects list
In http-push's get_delta(), we generate a list of pending objects by recursively processing trees and blobs, adding them to a linked list. And then we iterate over the list, adding a new request for each element. But since we iterate using the list head pointer, at the end it is NULL and all of the actual list structs have been leaked. We can fix this either by using a separate iterator and then calling object_list_free(), or by just freeing as we go. I picked the latter, just because it means we continue to shrink the list as we go, though I'm not sure it matters in practice (we call add_send_request() in the loop, but I don't think it ever looks at the global objects list itself). This fixes several leaks noticed in t5540. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3245a2a commit 92e1eb4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

http-push.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1374,9 +1374,13 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
13741374
}
13751375

13761376
while (objects) {
1377+
struct object_list *next = objects->next;
1378+
13771379
if (!(objects->item->flags & UNINTERESTING))
13781380
count += add_send_request(objects->item, lock);
1379-
objects = objects->next;
1381+
1382+
free(objects);
1383+
objects = next;
13801384
}
13811385

13821386
return count;

0 commit comments

Comments
 (0)