shithub: riscv

Download patch

ref: 2cfc72db7631a1416a9b983a38470584cc9407ac
parent: 8f91d94d19af3531d3f1afd4361f807c76f42cff
parent: 12716019bfdc3bedda1c8489d87a7cd316d016ef
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu May 3 08:28:41 EDT 2018

merge

--- a/sys/src/games/mines/ghost.c
+++ b/sys/src/games/mines/ghost.c
@@ -182,8 +182,8 @@
 		cl[ncl - 1 + j].mines = cl[i].pts == cl[i].mines;
 		cl[ncl - 1 + j].pts = 1;
 		cl[ncl - 1 + j].pt[0] = cl[i].pt[j];
-		cl[*lastq].next = i;
-		*lastq = i;
+		cl[*lastq].next = ncl - 1 + j;
+		*lastq = ncl - 1 + j;
 	}
 	cl[i].mines = cl[i].pts == cl[i].mines;
 	*nclp += cl[i].pts - 1;
@@ -255,7 +255,7 @@
 		next: ;
 		}
 		qi = q->next;
-		q->next = -1;
+		q->next = -2;
 	}
 	if(zero != 0){
 		for(i = 0, j = 0; i < *nclp; i++)
--- a/sys/src/libmp/port/mpdiv.c
+++ b/sys/src/libmp/port/mpdiv.c
@@ -22,7 +22,9 @@
 
 	// division by one or small powers of two
 	if(divisor->top == 1 && (divisor->p[0] & divisor->p[0]-1) == 0){
-		vlong r = (vlong)dividend->sign * (dividend->p[0] & divisor->p[0]-1);
+		vlong r = 0;
+		if(dividend->top > 0)
+			r = (vlong)dividend->sign * (dividend->p[0] & divisor->p[0]-1);
 		if(quotient != nil){
 			sign = divisor->sign;
 			for(s = 0; ((divisor->p[0] >> s) & 1) == 0; s++)
--- a/sys/src/libplumb/mesg.c
+++ b/sys/src/libplumb/mesg.c
@@ -76,21 +76,29 @@
 char*
 plumbpackattr(Plumbattr *attr)
 {
-	int n;
+	int n, l;
 	Plumbattr *a;
 	char *s, *t, *buf, *bufe;
 
 	if(attr == nil)
 		return nil;
-	if((buf = malloc(4096)) == nil)
+	n = 0;
+	for(a=attr; a!=nil; a=a->next){
+		l = Strlen(a->value);
+		if(l > n)
+			n = l;
+	}
+	if((buf = malloc(n*2+3)) == nil)
 		return nil;
-	bufe = buf + 4096;
+	bufe = buf + n*2+3;
 	n = 0;
 	for(a=attr; a!=nil; a=a->next)
 		n += Strlen(a->name) + 1 + Strlen(quote(a->value, buf, bufe)) + 1;
 	s = malloc(n);
-	if(s == nil)
+	if(s == nil){
+		free(buf);
 		return nil;
+	}
 	t = s;
 	*t = '\0';
 	for(a=attr; a!=nil; a=a->next){
@@ -221,9 +229,11 @@
 	char *q, *v, *buf, *bufe;
 	int c, quoting;
 
-	if((buf = malloc(4096)) == nil)
+	c = strlen(p) + 1;
+
+	if((buf = malloc(c)) == nil)
 		return nil;
-	bufe = buf + 4096;
+	bufe = buf + c;
 	attr = prev = nil;
 	while(*p!='\0' && *p!='\n'){
 		while(*p==' ' || *p=='\t')
@@ -340,6 +350,7 @@
 	m = malloc(sizeof(Plumbmsg));
 	if(m == nil)
 		return nil;
+	setmalloctag(m, getcallerpc(&buf));
 	memset(m, 0, sizeof(Plumbmsg));
 	if(morep != nil)
 		*morep = 0;
@@ -384,7 +395,11 @@
 Plumbmsg*
 plumbunpack(char *buf, int n)
 {
-	return plumbunpackpartial(buf, n, nil);
+	Plumbmsg *m;
+	m = plumbunpackpartial(buf, n, nil);
+	if(m != nil)
+		setmalloctag(m, getcallerpc(&buf));
+	return m;
 }
 
 Plumbmsg*