git: 9front

Download patch

ref: a1637d7db92cd4d1b6dca46d6047fd95d774c4f8
parent: 476895e00e0e466c55e6f1f3acff04cc01030719
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Wed May 1 15:03:56 EDT 2013

devpipe: fix channel and queue leaks (from erik quanstroms 9atom)

--- a/sys/src/9/port/devpipe.c
+++ b/sys/src/9/port/devpipe.c
@@ -61,6 +61,10 @@
 	Chan *c;
 
 	c = devattach('|', spec);
+	if(waserror()){
+		chanfree(c);
+		nexterror();
+	}
 	p = malloc(sizeof(Pipe));
 	if(p == 0)
 		exhausted("memory");
@@ -73,10 +77,11 @@
 	}
 	p->q[1] = qopen(conf.pipeqsize, 0, 0, 0);
 	if(p->q[1] == 0){
-		free(p->q[0]);
+		qfree(p->q[0]);
 		free(p);
 		exhausted("memory");
 	}
+	poperror();
 
 	lock(&pipealloc);
 	p->path = ++pipealloc.path;
--