Free the correct buffer in error handling.
Handle that malloc may return NULL.
This commit is contained in:
parent
6e87bd852f
commit
7e4c882a7c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpc_generic.c,v 1.7 2001/04/22 20:51:25 fvdl Exp $ */
|
||||
/* $NetBSD: rpc_generic.c,v 1.8 2001/05/26 00:22:22 kristerw Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -703,6 +703,8 @@ __rpc_uaddr2taddr_af(int af, const char *uaddr)
|
|||
}
|
||||
|
||||
ret = (struct netbuf *)malloc(sizeof *ret);
|
||||
if (ret == NULL)
|
||||
goto out;
|
||||
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
|
@ -730,7 +732,7 @@ __rpc_uaddr2taddr_af(int af, const char *uaddr)
|
|||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_port = htons(port);
|
||||
if (inet_pton(AF_INET6, addrstr, &sin6->sin6_addr) <= 0) {
|
||||
free(sin);
|
||||
free(sin6);
|
||||
free(ret);
|
||||
ret = NULL;
|
||||
goto out;
|
||||
|
|
Loading…
Reference in New Issue