Skip to content

Commit 8628ace

Browse files
rscharfegitster
authored andcommitted
commit-reach: fix cast in compare_commits_by_gen()
The elements of the array to be sorted are commit pointers, so the comparison function gets handed references to these pointers, not pointers to commit objects. Cast to the right type and dereference once to correctly get the commit reference. Found using Clang's ASan and t5500. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4067a64 commit 8628ace

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

commit-reach.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ int commit_contains(struct ref_filter *filter, struct commit *commit,
526526

527527
static int compare_commits_by_gen(const void *_a, const void *_b)
528528
{
529-
const struct commit *a = (const struct commit *)_a;
530-
const struct commit *b = (const struct commit *)_b;
529+
const struct commit *a = *(const struct commit * const *)_a;
530+
const struct commit *b = *(const struct commit * const *)_b;
531531

532532
if (a->generation < b->generation)
533533
return -1;

0 commit comments

Comments
 (0)