diff options
author | markm <markm@FreeBSD.org> | 2003-07-21 20:55:37 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2003-07-21 20:55:37 +0000 |
commit | b03a1147332ddbe41f75a85dd618e5b77d7554ef (patch) | |
tree | ea6ad8ed23017ab477d64016a2b859417bd79904 | |
parent | 39a19ad3a21af68c0aa4f245b1b5f49d75964ea8 (diff) | |
download | FreeBSD-src-b03a1147332ddbe41f75a85dd618e5b77d7554ef.zip FreeBSD-src-b03a1147332ddbe41f75a85dd618e5b77d7554ef.tar.gz |
Replace an alloca() call with a slightly more standard malloc()/free()
pair.
-rw-r--r-- | usr.bin/getconf/getconf.c | 11 |
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"); } } |