summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/uipc_syscalls.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 33ddae83b58..a88b971cc6f 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.34 2000/11/16 20:02:19 provos Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.35 2001/02/09 00:04:16 itojun Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -211,8 +211,8 @@ sys_accept(p, v, retval)
fp->f_ops = &socketops;
fp->f_data = (caddr_t)so;
nam = m_get(M_WAIT, MT_SONAME);
- (void) soaccept(so, nam);
- if (SCARG(uap, name)) {
+ error = soaccept(so, nam);
+ if (!error && SCARG(uap, name)) {
if (namelen > nam->m_len)
namelen = nam->m_len;
/* SHOULD COPY OUT A CHAIN HERE */
@@ -222,6 +222,11 @@ sys_accept(p, v, retval)
(caddr_t)SCARG(uap, anamelen),
sizeof (*SCARG(uap, anamelen)));
}
+ /* if an error occured, free the file descriptor */
+ if (error) {
+ fdremove(p->p_fd, tmpfd);
+ ffree(fp);
+ }
m_freem(nam);
splx(s);
return (error);