die if strdup failure
This commit is contained in:
parent
35ddf151dc
commit
07780ab297
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: traceroute.c,v 1.56 2002/11/16 03:36:17 itojun Exp $ */
|
||||
/* $NetBSD: traceroute.c,v 1.57 2002/11/16 15:43:52 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997
|
||||
|
@ -29,7 +29,7 @@ static const char rcsid[] =
|
|||
#else
|
||||
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\n\
|
||||
The Regents of the University of California. All rights reserved.\n");
|
||||
__RCSID("$NetBSD: traceroute.c,v 1.56 2002/11/16 03:36:17 itojun Exp $");
|
||||
__RCSID("$NetBSD: traceroute.c,v 1.57 2002/11/16 15:43:52 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1487,6 +1487,11 @@ gethostinfo(char *hostname)
|
|||
}
|
||||
if (inet_aton(hostname, &addr) != 0) {
|
||||
hi->name = strdup(hostname);
|
||||
if (!hi->name) {
|
||||
Fprintf(stderr, "%s: strdup %s\n", prog,
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
hi->n = 1;
|
||||
hi->addrs = calloc(1, sizeof(hi->addrs[0]));
|
||||
if (hi->addrs == NULL) {
|
||||
|
@ -1508,6 +1513,10 @@ gethostinfo(char *hostname)
|
|||
exit(1);
|
||||
}
|
||||
hi->name = strdup(hp->h_name);
|
||||
if (!hi->name) {
|
||||
Fprintf(stderr, "%s: strdup %s\n", prog, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
for (n = 0, p = hp->h_addr_list; *p != NULL; ++n, ++p)
|
||||
continue;
|
||||
hi->n = n;
|
||||
|
|
Loading…
Reference in New Issue