code: plan9front

Download patch

ref: 3710ed60fddcc6f943a23f205d4c92984758834e
parent: be0b39f9c57cc4c2768c341fcf87a15fcab0165c
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Dec 7 19:20:32 EST 2021

git: fully init objq

we were leaving objq.best uninitialized, and
would therefore read garbage if we didn't
find a best match.

--- a/sys/src/cmd/git/ref.c
+++ b/sys/src/cmd/git/ref.c
@@ -217,6 +217,7 @@
 
 	osinit(&keep);
 	osinit(&drop);
+	memset(&objq, 0, sizeof(objq));
 	qinit(&objq);
 	objq.head = head;
 	objq.nhead = nhead;
@@ -335,9 +336,9 @@
 
 	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