diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-08-14 21:39:45 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-08-14 21:39:45 +0000 |
commit | fbe7a4e21ce2effe646980ca1214c125d94c70fd (patch) | |
tree | 50eb4ae3c83a05be96515dfbe68af415625afbfa /lib/libc/rpc/pmap_rmt.c | |
parent | eef299572b3aae714384affd3dae3292c7325f78 (diff) |
realloc repair
Diffstat (limited to 'lib/libc/rpc/pmap_rmt.c')
-rw-r--r-- | lib/libc/rpc/pmap_rmt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index befeadae989..e8f8750e233 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -28,7 +28,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: pmap_rmt.c,v 1.15 1997/07/09 03:05:05 deraadt Exp $"; +static char *rcsid = "$OpenBSD: pmap_rmt.c,v 1.16 1998/08/14 21:39:37 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -166,7 +166,7 @@ newgetbroadcastnets(addrsp, sock) struct in_addr **addrsp; int sock; /* any valid socket will do */ { - char *inbuf = NULL; + char *inbuf = NULL, *ninbuf; struct ifconf ifc; struct ifreq ifreq, *ifr; struct sockaddr_in *sin; @@ -177,9 +177,13 @@ newgetbroadcastnets(addrsp, sock) while (1) { ifc.ifc_len = inbuflen; - ifc.ifc_buf = inbuf = realloc(inbuf, inbuflen); - if (inbuf == NULL) + ninbuf = realloc(inbuf, inbuflen); + if (ninbuf == NULL) { + if (inbuf) + free(inbuf); return (0); + } + ifc.ifc_buf = inbuf = ninbuf; if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { perror("broadcast: ioctl (get interface configuration)"); free(inbuf); |