From cd68f9fd9f2baef40ae0855f613088ced5134c9a Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 16 Oct 1996 06:23:34 +0000 Subject: check malloc() ret val! --- usr.sbin/mrinfo/mrinfo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'usr.sbin/mrinfo') diff --git a/usr.sbin/mrinfo/mrinfo.c b/usr.sbin/mrinfo/mrinfo.c index 692b5250326..5be11dcd36d 100644 --- a/usr.sbin/mrinfo/mrinfo.c +++ b/usr.sbin/mrinfo/mrinfo.c @@ -164,7 +164,7 @@ log(severity, syserr, format, va_alist) strncat(fmt, format, 80); vfprintf(stderr, fmt, ap); if (syserr == 0) - fprintf(stderr, "\n"); + fputc('\n', stderr); else if (syserr < sys_nerr) fprintf(stderr, ": %s\n", sys_errlist[syserr]); else @@ -379,8 +379,10 @@ main(argc, argv) if ((target_addr = inet_addr(host)) != -1) { hp = &bogus; hp->h_length = sizeof(target_addr); - hp->h_addr_list = (char **)malloc(2 * sizeof(char *)); - hp->h_addr_list[0] = malloc(hp->h_length); + if (!(hp->h_addr_list = (char **)malloc(2 * sizeof(char *)))) + err(1, "can't allocate memory"); + if (!(hp->h_addr_list[0] = malloc(hp->h_length))) + err(1, "can't allocate memory"); memcpy(hp->h_addr_list[0], &target_addr, hp->h_length); hp->h_addr_list[1] = 0; } else -- cgit v1.2.3