summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/config.y
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2010-03-30 13:46:40 +0000
committerru <ru@FreeBSD.org>2010-03-30 13:46:40 +0000
commit5562af42b475b5dd9510c3aae83fb5c13b2461aa (patch)
treea397f140c6755a88a4687730d41abc1141ca66c4 /usr.sbin/config/config.y
parent09e7af977a9c3aa17fc324806c8ba6d8a7ab3c72 (diff)
downloadFreeBSD-src-5562af42b475b5dd9510c3aae83fb5c13b2461aa.zip
FreeBSD-src-5562af42b475b5dd9510c3aae83fb5c13b2461aa.tar.gz
- Handle calloc() allocation failures.
- Fixed a comment. - 2 -> EXIT_FAILURE in some places. - errx() -> err() where appropriate. PR: 144644 Submitted by: Garrett Cooper
Diffstat (limited to 'usr.sbin/config/config.y')
-rw-r--r--usr.sbin/config/config.y10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 9425daf..19f2779 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -166,6 +166,8 @@ Config_spec:
CPU Save_id {
struct cputype *cp =
(struct cputype *)calloc(1, sizeof (struct cputype));
+ if (cp == NULL)
+ err(EXIT_FAILURE, "calloc");
cp->cpu_name = $2;
SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
} |
@@ -197,6 +199,8 @@ Config_spec:
struct hint *hint;
hint = (struct hint *)calloc(1, sizeof (struct hint));
+ if (hint == NULL)
+ err(EXIT_FAILURE, "calloc");
hint->hint_name = $2;
STAILQ_INSERT_TAIL(&hints, hint, hint_next);
hintmode = 1;
@@ -331,6 +335,8 @@ newfile(char *name)
struct files_name *nl;
nl = (struct files_name *) calloc(1, sizeof *nl);
+ if (nl == NULL)
+ err(EXIT_FAILURE, "calloc");
nl->f_name = name;
STAILQ_INSERT_TAIL(&fntab, nl, f_next);
}
@@ -364,6 +370,8 @@ newdev(char *name)
}
np = (struct device *) calloc(1, sizeof *np);
+ if (np == NULL)
+ err(EXIT_FAILURE, "calloc");
np->d_name = name;
STAILQ_INSERT_TAIL(&dtab, np, d_next);
}
@@ -422,6 +430,8 @@ newopt(struct opt_head *list, char *name, char *value, int append)
}
op = (struct opt *)calloc(1, sizeof (struct opt));
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = name;
op->op_ownfile = 0;
op->op_value = value;
OpenPOWER on IntegriCloud