summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/rpc_generic.c
diff options
context:
space:
mode:
authormatteo <matteo@FreeBSD.org>2007-09-20 22:35:24 +0000
committermatteo <matteo@FreeBSD.org>2007-09-20 22:35:24 +0000
commit814a1d9415f5a007603e5f6fd660d6d5b2f02013 (patch)
treeb9ebd242caa30861a0972b4364ebf92431d7d812 /lib/libc/rpc/rpc_generic.c
parentce87421a551888042a53154c5589c1726acfb3ca (diff)
downloadFreeBSD-src-814a1d9415f5a007603e5f6fd660d6d5b2f02013.zip
FreeBSD-src-814a1d9415f5a007603e5f6fd660d6d5b2f02013.tar.gz
Fix some improper handling of malloc failures
PR: bin/83344 , kern/81987 Reviewed by: alfred Approved by: re (kensmith) MFC after: 1 week
Diffstat (limited to 'lib/libc/rpc/rpc_generic.c')
-rw-r--r--lib/libc/rpc/rpc_generic.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c
index a5168c4..81bd92b 100644
--- a/lib/libc/rpc/rpc_generic.c
+++ b/lib/libc/rpc/rpc_generic.c
@@ -319,10 +319,8 @@ __rpc_setconf(nettype)
case _RPC_NETPATH:
case _RPC_CIRCUIT_N:
case _RPC_DATAGRAM_N:
- if (!(handle->nhandle = setnetpath())) {
- free(handle);
- return (NULL);
- }
+ if (!(handle->nhandle = setnetpath()))
+ goto failed;
handle->nflag = TRUE;
break;
case _RPC_VISIBLE:
@@ -332,16 +330,19 @@ __rpc_setconf(nettype)
case _RPC_UDP:
if (!(handle->nhandle = setnetconfig())) {
syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
- free(handle);
- return (NULL);
+ goto failed;
}
handle->nflag = FALSE;
break;
default:
- return (NULL);
+ goto failed;
}
return (handle);
+
+failed:
+ free(handle);
+ return (NULL);
}
/*
OpenPOWER on IntegriCloud