summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-07 13:00:17 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-07 13:00:17 +0000
commit9633321da4f4cc30095180b25274ad9e7d9ad634 (patch)
tree02a1edf0cc9504d165fa1123d2316e7bb41f6005
parent19acf78b27a75dc6027e92fb0b7a1cee7208d237 (diff)
mem leak, short malloc; netbsd pr#3000, minoura@kw.netlaputa.or.jp
-rw-r--r--sys/miscfs/union/union_subr.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/miscfs/union/union_subr.c b/sys/miscfs/union/union_subr.c
index 9a5827bccf1..408de9951e2 100644
--- a/sys/miscfs/union/union_subr.c
+++ b/sys/miscfs/union/union_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: union_subr.c,v 1.2 1996/02/27 08:09:00 niklas Exp $ */
+/* $OpenBSD: union_subr.c,v 1.3 1996/12/07 13:00:16 deraadt Exp $ */
/* $NetBSD: union_subr.c,v 1.18 1996/02/09 22:41:10 christos Exp $ */
/*
@@ -742,6 +742,10 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen)
error = relookup(dvp, vpp, cn);
if (!error)
vrele(dvp);
+ else {
+ free(cn->cn_pnbuf, M_NAMEI);
+ cn->cn_pnbuf = 0;
+ }
return (error);
}
@@ -884,7 +888,7 @@ union_vn_create(vpp, un, p)
* copied in the first place).
*/
cn.cn_namelen = strlen(un->un_path);
- cn.cn_pnbuf = (caddr_t) malloc(cn.cn_namelen, M_NAMEI, M_WAITOK);
+ cn.cn_pnbuf = (caddr_t) malloc(cn.cn_namelen+1, M_NAMEI, M_WAITOK);
bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1);
cn.cn_nameiop = CREATE;
cn.cn_flags = (LOCKPARENT|HASBUF|SAVENAME|SAVESTART|ISLASTCN);