summaryrefslogtreecommitdiff
path: root/commit-reach.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2018-10-01 19:16:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-22 22:57:47 (GMT)
commit8628ace2691510dc856e2a9c735706fa8f0620e1 (patch)
treec181c4c78406040d5fb424175d6473bcc2c095f2 /commit-reach.c
parent4067a64672f9db8ca38d5a2682a7cdba7938c18b (diff)
downloadgit-8628ace2691510dc856e2a9c735706fa8f0620e1.zip
git-8628ace2691510dc856e2a9c735706fa8f0620e1.tar.gz
git-8628ace2691510dc856e2a9c735706fa8f0620e1.tar.bz2
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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-reach.c')
-rw-r--r--commit-reach.c4
1 files changed, 2 insertions, 2 deletions
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;