From 105ebc327abe965cf11242e6c300d28979938f5e Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 29 Jan 2012 03:21:09 +0100 Subject: [PATCH] sam: fix memory leak for name in fwrite --- sys/src/cmd/sam/io.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/src/cmd/sam/io.c b/sys/src/cmd/sam/io.c index 3fee95a05..f995bb7c9 100644 --- a/sys/src/cmd/sam/io.c +++ b/sys/src/cmd/sam/io.c @@ -41,6 +41,7 @@ writef(File *f) f->qidpath = qid; f->mtime = mtime; warn_S(Wdate, &genstr); + free(name); return; } if(genc) @@ -49,8 +50,10 @@ writef(File *f) if((io=create(genc, 1, 0666L)) < 0) error_r(Ecreate, genc); dprint("%s: ", genc); - if(statfd(io, 0, 0, 0, &length, &appendonly) > 0 && appendonly && length>0) + if(statfd(io, 0, 0, 0, &length, &appendonly) > 0 && appendonly && length>0){ + free(name); error(Eappend); + } n = writeio(f); if(f->name.s[0]==0 || samename){ if(addr.r.p1==0 && addr.r.p2==f->nc) @@ -70,6 +73,7 @@ writef(File *f) checkqid(f); } } + free(name); } Posn