]> git.ipfire.org Git - thirdparty/git.git/commit
gc: fix cast in compare_tasks_by_selection()
authorRené Scharfe <l.s.r@web.de>
Tue, 17 Nov 2020 21:59:49 +0000 (22:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Nov 2020 22:15:58 +0000 (14:15 -0800)
commita1c74791d5ffaa6d723abb14cebf556499c3c4cb
tree172fbfdecf391c76ecd71d6ca78f24d366e8aa86
parentfaefdd61ec7c7f6f3c8c9907891465ac9a2a1475
gc: fix cast in compare_tasks_by_selection()

compare_tasks_by_selection() is used with QSORT and gets passed pointers
to the elements of "static struct maintenance_task tasks[]".  It casts
the *addresses* of these passed pointers to element pointers, though,
and thus effectively compares some unrelated values from the stack.  Fix
the casts to actually compare array elements.

Detected by USan (make SANITIZE=undefined test).

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c