From 814a1d9415f5a007603e5f6fd660d6d5b2f02013 Mon Sep 17 00:00:00 2001 From: matteo Date: Thu, 20 Sep 2007 22:35:24 +0000 Subject: Fix some improper handling of malloc failures PR: bin/83344 , kern/81987 Reviewed by: alfred Approved by: re (kensmith) MFC after: 1 week --- lib/libc/rpc/rpc_generic.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/libc/rpc/rpc_generic.c') 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); } /* -- cgit v1.1