diff options
author | matteo <matteo@FreeBSD.org> | 2007-09-20 22:35:24 +0000 |
---|---|---|
committer | matteo <matteo@FreeBSD.org> | 2007-09-20 22:35:24 +0000 |
commit | 814a1d9415f5a007603e5f6fd660d6d5b2f02013 (patch) | |
tree | b9ebd242caa30861a0972b4364ebf92431d7d812 /lib/libc/rpc/getnetpath.c | |
parent | ce87421a551888042a53154c5589c1726acfb3ca (diff) | |
download | FreeBSD-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/getnetpath.c')
-rw-r--r-- | lib/libc/rpc/getnetpath.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/libc/rpc/getnetpath.c b/lib/libc/rpc/getnetpath.c index a0a4bfd..0563544 100644 --- a/lib/libc/rpc/getnetpath.c +++ b/lib/libc/rpc/getnetpath.c @@ -101,7 +101,7 @@ setnetpath() if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) { free(np_sessionp); syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); - return (NULL); + goto failed; } np_sessionp->valid = NP_VALID; np_sessionp->ncp_list = NULL; @@ -110,15 +110,18 @@ setnetpath() } else { (void) endnetconfig(np_sessionp->nc_handlep);/* won't need nc session*/ np_sessionp->nc_handlep = NULL; - if ((np_sessionp->netpath = malloc(strlen(npp)+1)) == NULL) { - free(np_sessionp); - return (NULL); - } else { + if ((np_sessionp->netpath = malloc(strlen(npp)+1)) == NULL) + goto failed; + else { (void) strcpy(np_sessionp->netpath, npp); } } np_sessionp->netpath_start = np_sessionp->netpath; return ((void *)np_sessionp); + +failed: + free(np_sessionp); + return (NULL); } /* |