shithub: riscv

Download patch

ref: 21cedbedb24c2af04ac3b141ff6ce112c5d6e582
parent: 1c521567a170e1e416f147de501d53414e71fb05
author: cinap_lenrek <cinap_lenrek@rei2.9hal>
date: Sat Jan 28 15:29:55 EST 2012

rio: fix memory leak for w->dir

--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -1190,8 +1190,10 @@
 	}
 	wsetpid(w, pid, 1);
 	wsetname(w);
-	if(dir)
+	if(dir){
+		free(w->dir);
 		w->dir = estrdup(dir);
+	}
 	chanfree(cpid);
 	return w;
 }
--- a/sys/src/cmd/rio/util.c
+++ b/sys/src/cmd/rio/util.c
@@ -81,6 +81,7 @@
 	p = malloc(strlen(s)+1);
 	if(p == nil)
 		error("strdup failed");
+	setmalloctag(p, getcallerpc(&s));
 	strcpy(p, s);
 	return p;
 }
--