From 283bae6f03b4b075d5a19a967a0c24cebd000a19 Mon Sep 17 00:00:00 2001 From: mbr Date: Sat, 9 Sep 2006 22:33:21 +0000 Subject: Sync with NetBSD rev. 1.16 + 1.17 Coverity CID 2292: Plug memory leak. Coverity CID 2291: Move function call before allocating storage to prevent memory leak on error. MFC after: 1 month --- lib/libc/rpc/svc_vc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c index 50c6651..6fcbb21 100644 --- a/lib/libc/rpc/svc_vc.c +++ b/lib/libc/rpc/svc_vc.c @@ -135,13 +135,14 @@ svc_vc_create(fd, sendsize, recvsize) struct sockaddr_storage sslocal; socklen_t slen; + if (!__rpc_fd2sockinfo(fd, &si)) + return NULL; + r = mem_alloc(sizeof(*r)); if (r == NULL) { warnx("svc_vc_create: out of memory"); goto cleanup_svc_vc_create; } - if (!__rpc_fd2sockinfo(fd, &si)) - return NULL; r->sendsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsize); r->recvsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsize); r->maxrec = __svc_maxrec; @@ -177,6 +178,8 @@ svc_vc_create(fd, sendsize, recvsize) xprt_register(xprt); return (xprt); cleanup_svc_vc_create: + if (xprt) + mem_free(xprt, sizeof(*xprt)); if (r != NULL) mem_free(r, sizeof(*r)); return (NULL); -- cgit v1.1