From 6e4cd31d99135e6e7da9973d600ba81288416380 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Fri, 1 Dec 2000 09:59:40 +0000 Subject: [PATCH] Exit if malloc() returns NULL Submitted by: Chris Faulhaber --- bin/date/vary.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/date/vary.c b/bin/date/vary.c index 7fba4221116b..7ee8a4fe8d90 100644 --- a/bin/date/vary.c +++ b/bin/date/vary.c @@ -29,6 +29,7 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include #include #include #include @@ -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;