summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2003-07-21 20:55:37 +0000
committermarkm <markm@FreeBSD.org>2003-07-21 20:55:37 +0000
commitb03a1147332ddbe41f75a85dd618e5b77d7554ef (patch)
treeea6ad8ed23017ab477d64016a2b859417bd79904 /usr.bin
parent39a19ad3a21af68c0aa4f245b1b5f49d75964ea8 (diff)
downloadFreeBSD-src-b03a1147332ddbe41f75a85dd618e5b77d7554ef.zip
FreeBSD-src-b03a1147332ddbe41f75a85dd618e5b77d7554ef.tar.gz
Replace an alloca() call with a slightly more standard malloc()/free()
pair.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/getconf/getconf.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c
index 8bfeb93..14345c6 100644
--- a/usr.bin/getconf/getconf.c
+++ b/usr.bin/getconf/getconf.c
@@ -148,9 +148,14 @@ do_confstr(const char *name, int key)
if (len == 0) {
printf("undefined\n");
} else {
- buf = alloca(len);
- confstr(key, buf, len);
- printf("%s\n", buf);
+ buf = malloc(len);
+ if (buf != NULL) {
+ confstr(key, buf, len);
+ printf("%s\n", buf);
+ free(buf);
+ }
+ else
+ err(EX_OSERR, "malloc: confstr");
}
}
OpenPOWER on IntegriCloud