From 00bea96dadb6ec6574f7a46ccc58052337f8783d Mon Sep 17 00:00:00 2001 From: mbr Date: Mon, 27 Jan 2003 22:22:59 +0000 Subject: Free the correct buffer in error handling. Handle that malloc may return NULL. NetBSD Rev. 1.8 Reviewed by: phk Obtained from: NetBSD --- lib/libc/rpc/rpc_generic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (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 180b5ee..3e33e6d 100644 --- a/lib/libc/rpc/rpc_generic.c +++ b/lib/libc/rpc/rpc_generic.c @@ -688,6 +688,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: @@ -715,7 +717,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; -- cgit v1.1