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
This commit is contained in:
parent
8306b5154c
commit
794295bab8
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user