Exit if malloc() returns NULL

Submitted by: Chris Faulhaber <jedgar@fxp.org>
This commit is contained in:
Brian Somers 2000-12-01 09:59:40 +00:00
parent 1533a5cfd2
commit 6e4cd31d99
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69457

View File

@ -29,6 +29,7 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <err.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
@ -93,7 +94,8 @@ vary_append(struct vary *v, char *arg)
} else
nextp = &result;
*nextp = (struct vary *)malloc(sizeof(struct vary));
if ((*nextp = (struct vary *)malloc(sizeof(struct vary))) == NULL)
err(1, "malloc");
(*nextp)->arg = arg;
(*nextp)->next = NULL;
return result;