summaryrefslogtreecommitdiff
path: root/usr.sbin/timed
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-16 22:12:07 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-16 22:12:07 +0000
commiteb0f6516722926f0382ef0930bca8fffa0ee075a (patch)
treec0900551a96197fa8eee45719dfc73fa638953b9 /usr.sbin/timed
parent8b89772ddda944f522b1c1ab69ed29a030eccf2d (diff)
fix realloc leak
Diffstat (limited to 'usr.sbin/timed')
-rw-r--r--usr.sbin/timed/timed/timed.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c
index 678a45f128c..d6ddfc6b6e0 100644
--- a/usr.sbin/timed/timed/timed.c
+++ b/usr.sbin/timed/timed/timed.c
@@ -42,7 +42,7 @@ static char sccsid[] = "@(#)timed.c 5.1 (Berkeley) 5/11/93";
#endif /* not lint */
#ifdef sgi
-#ident "$Revision: 1.6 $"
+#ident "$Revision: 1.7 $"
#endif /* sgi */
#define TSPTYPES
@@ -386,12 +386,17 @@ main(int argc, char **argv)
nt->net <<= 8;
}
while (1) {
+ char *ninbuf;
+
ifc.ifc_len = inlen;
- ifc.ifc_buf = inbuf = realloc(inbuf, inlen);
- if (inbuf == NULL) {
+ ninbuf = realloc(inbuf, inlen);
+ if (ninbuf == NULL) {
+ if (inbuf)
+ free(inbuf);
close(sock);
return (-1);
}
+ ifc.ifc_buf = inbuf = ninbuf;
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
(void) close(sock);
free(inbuf);