summaryrefslogtreecommitdiff
path: root/kerberosIV/kauth
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1998-08-16 02:42:12 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1998-08-16 02:42:12 +0000
commit364a0613877e4712a7614d08e62ec043adfbf94b (patch)
tree6d958783b2dd21a5d023a0db66ec592659ae63ad /kerberosIV/kauth
parent7f6450fdf2329ea9c097d81109b3f08742bf8a4d (diff)
realloc fixes
Diffstat (limited to 'kerberosIV/kauth')
-rw-r--r--kerberosIV/kauth/rkinit.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/kerberosIV/kauth/rkinit.c b/kerberosIV/kauth/rkinit.c
index 615b6592583..713c9df9547 100644
--- a/kerberosIV/kauth/rkinit.c
+++ b/kerberosIV/kauth/rkinit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rkinit.c,v 1.1 1997/12/18 22:28:05 art Exp $ */
+/* $OpenBSD: rkinit.c,v 1.2 1998/08/16 02:42:10 art Exp $ */
/* $KTH: rkinit.c,v 1.19 1997/04/01 08:17:33 joda Exp $ */
/*
@@ -47,6 +47,7 @@ getalladdrs (char *hostname, unsigned *count)
struct hostent *hostent;
struct in_addr **h;
struct in_addr *addr;
+ struct in_addr *temp;
unsigned naddr;
unsigned maxaddr;
@@ -74,19 +75,23 @@ getalladdrs (char *hostname, unsigned *count)
h++) {
if (naddr >= maxaddr) {
maxaddr *= 2;
- addr = realloc (addr, sizeof(*addr) * maxaddr);
- if (addr == NULL) {
+ temp = realloc (addr, sizeof(*addr) * maxaddr);
+ if (temp == NULL) {
warnx ("out of memory");
+ free(addr);
return NULL;
}
+ addr = temp;
}
addr[naddr++] = **h;
}
- addr = realloc (addr, sizeof(*addr) * naddr);
- if (addr == NULL) {
+ temp = realloc (addr, sizeof(*addr) * naddr);
+ if (temp == NULL) {
warnx ("out of memory");
+ free(addr);
return NULL;
}
+ addr = temp;
*count = naddr;
return addr;
}