diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-08-14 21:30:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-08-14 21:30:34 +0000 |
commit | eef299572b3aae714384affd3dae3292c7325f78 (patch) | |
tree | d547b3c5009cdfb803b36dcb217182a6e4c7729e | |
parent | 283fd495b05f3ef5c93d53cd4be8b0f97cb4f416 (diff) |
realloc repair
-rw-r--r-- | lib/libpcap/inet.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libpcap/inet.c b/lib/libpcap/inet.c index 6f55b9d4a7b..265dd39c5bd 100644 --- a/lib/libpcap/inet.c +++ b/lib/libpcap/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.8 1998/07/14 00:14:01 deraadt Exp $ */ +/* $OpenBSD: inet.c,v 1.9 1998/08/14 21:30:33 deraadt Exp $ */ /* * Copyright (c) 1994, 1995, 1996 @@ -86,7 +86,7 @@ pcap_lookupdev(errbuf) register char *errbuf; { register int fd, minunit, n; - register char *cp, *ibuf = NULL; + register char *cp, *ibuf = NULL, *nibuf; register struct ifreq *ifrp, *ifend, *ifnext, *mp; struct ifconf ifc; struct ifreq ifr; @@ -101,11 +101,14 @@ pcap_lookupdev(errbuf) } while (1) { ifc.ifc_len = len; - ifc.ifc_buf = ibuf = realloc(ibuf, len); - if (ibuf == NULL) { + nibuf = realloc(ibuf, len); + if (nibuf == NULL) { + if (ibuf) + free(ibuf); close(fd); return (NULL); } + ifc.ifc_buf = ibuf = nibuf; if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0) { (void)close(fd); free(ibuf); |