shithub: riscv

Download patch

ref: 19fda05a6dbf5f7529a42a6028b8a0f45c237a8b
parent: 158b5a3a219fde6c353a46a2c1170176a64959ce
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;
--