From 8628ace2691510dc856e2a9c735706fa8f0620e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Mon, 1 Oct 2018 21:16:01 +0200 Subject: 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 Signed-off-by: Junio C Hamano diff --git a/commit-reach.c b/commit-reach.c index 5a84544..c6de0cc 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -526,8 +526,8 @@ int commit_contains(struct ref_filter *filter, struct commit *commit, static int compare_commits_by_gen(const void *_a, const void *_b) { - const struct commit *a = (const struct commit *)_a; - const struct commit *b = (const struct commit *)_b; + const struct commit *a = *(const struct commit * const *)_a; + const struct commit *b = *(const struct commit * const *)_b; if (a->generation < b->generation) return -1; -- cgit v0.10.2-6-g49f6