git: 9front

Download patch

ref: 4e3100d5d994a98af094c90f3d76566800cb3871
parent: 9262677641b7cd620aa41c93cbaaccf68be6ba59
author: cinap_lenrek <cinap_lenrek@localhost>
date: Thu Jun 16 16:04:43 EDT 2011

9660srv: fix memory leak

--- a/sys/src/cmd/9660srv/main.c
+++ b/sys/src/cmd/9660srv/main.c
@@ -246,6 +246,7 @@
 	p = malloc(n);
 	if(p == 0)
 		error("no memory");
+	setmalloctag(p, getcallerpc(&n));
 	return p;
 }
 
@@ -365,8 +366,6 @@
 	}
 
 	if(waserror()){
-		if(nf != nil)
-			xfile(req->newfid, Clunk);
 		if(rep->nwqid == req->nwname){
 			if(oldlen)
 				free(oldptr);
@@ -378,6 +377,8 @@
 			f->ptr = oldptr;
 			f->len = oldlen;
 		}
+		if(nf != nil)
+			xfile(req->newfid, Clunk);
 		if(rep->nwqid==req->nwname || rep->nwqid > 0){
 			err_msg[0] = '\0';
 			return;
--