From d0bb0f775761a292caa2d2720bd91a51b469710b Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 1 May 2013 21:56:02 +0200 Subject: chan: fix potential path leak on clone in namec() (from erik quanstroms 9atom) --- sys/src/9/port/chan.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sys/src/9/port/chan.c') diff --git a/sys/src/9/port/chan.c b/sys/src/9/port/chan.c index 262b0703d..d0d0ce4bb 100644 --- a/sys/src/9/port/chan.c +++ b/sys/src/9/port/chan.c @@ -1472,6 +1472,10 @@ namec(char *aname, int amode, int omode, ulong perm) /* save&update the name; domount might change c */ path = c->path; incref(path); + if(waserror()){ + pathclose(path); + nexterror(); + } m = nil; if(!nomount) domount(&c, &m, &path); @@ -1482,6 +1486,7 @@ namec(char *aname, int amode, int omode, ulong perm) /* now it's our copy anyway, we can put the name back */ pathclose(c->path); c->path = path; + poperror(); /* record whether c is on a mount point */ c->ismtpt = m!=nil; -- cgit v1.2.3