]> git.ipfire.org Git - thirdparty/git.git/commit
promisor-remote: skip move_to_tail when no-op
authorEmily Shaffer <emilyshaffer@google.com>
Mon, 30 Sep 2019 22:03:55 +0000 (15:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Oct 2019 05:56:54 +0000 (14:56 +0900)
commit65904b8b2b27c71a96d8a9c37c19bcc8f2d1380c
treebe344801a58957b8f19b2eb9de64f213da643065
parent8464f94aeb2a5eb1ba834460b695b171b95e3fc0
promisor-remote: skip move_to_tail when no-op

Previously, when promisor_remote_move_to_tail() is called for a
promisor_remote which is currently the final element in promisors, a
cycle is created in the promisors linked list. This cycle leads to a
double free later on in promisor_remote_clear() when the final element
of the promisors list is removed: promisors is set to promisors->next (a
no-op, as promisors->next == promisors); the previous value of promisors
is free()'d; then the new value of promisors (which is equal to the
previous value of promisors) is also free()'d. This double-free error
was unrecoverable for the user without removing the filter or re-cloning
the repo and hoping to miss this edge case.

Now, when promisor_remote_move_to_tail() would be a no-op, just do a
no-op. In cases of promisor_remote_move_to_tail() where r is not already
at the tail of the list, it works as before.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Acked-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
promisor-remote.c
t/t0410-partial-clone.sh