From 3710ed60fddcc6f943a23f205d4c92984758834e Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Wed, 8 Dec 2021 00:20:32 +0000 Subject: [PATCH] git: fully init objq we were leaving objq.best uninitialized, and would therefore read garbage if we didn't find a best match. --- sys/src/cmd/git/ref.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/src/cmd/git/ref.c b/sys/src/cmd/git/ref.c index ba6f6f830..8308ac205 100644 --- a/sys/src/cmd/git/ref.c +++ b/sys/src/cmd/git/ref.c @@ -217,6 +217,7 @@ paint(Hash *head, int nhead, Hash *tail, int ntail, Object ***res, int *nres, in osinit(&keep); osinit(&drop); + memset(&objq, 0, sizeof(objq)); qinit(&objq); objq.head = head; objq.nhead = nhead; @@ -335,9 +336,9 @@ ancestor(Object *a, Object *b) if(paint(&a->hash, 1, &b->hash, 1, &o, &n, 1) == -1 || n == 0) return nil; - r = o[0]; + r = ref(o[0]); free(o); - return ref(r); + return r; } int