From 0cd41dca9a25a3249863ae2d9fef325f8bf7ba01 Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Mon, 21 Jul 2003 20:55:37 +0000 Subject: [PATCH] Replace an alloca() call with a slightly more standard malloc()/free() pair. --- usr.bin/getconf/getconf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c index 8bfeb93c471..14345c62411 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"); } }