Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/rpc Free the correct buffer in error handling.



details:   https://anonhg.NetBSD.org/src/rev/28c831786833
branches:  trunk
changeset: 510285:28c831786833
user:      kristerw <kristerw%NetBSD.org@localhost>
date:      Sat May 26 00:22:22 2001 +0000

description:
Free the correct buffer in error handling.
Handle that malloc may return NULL.

diffstat:

 lib/libc/rpc/rpc_generic.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 932842d59612 -r 28c831786833 lib/libc/rpc/rpc_generic.c
--- a/lib/libc/rpc/rpc_generic.c        Sat May 26 00:10:06 2001 +0000
+++ b/lib/libc/rpc/rpc_generic.c        Sat May 26 00:22:22 2001 +0000
@@ -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 @@
        }
 
        ret = (struct netbuf *)malloc(sizeof *ret);
+       if (ret == NULL)
+               goto out;
        
        switch (af) {
        case AF_INET:
@@ -730,7 +732,7 @@
                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;



Home | Main Index | Thread Index | Old Index