summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-01-14 18:28:16 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-01-14 18:28:16 +0000
commite99b7f1a2ce82cced0bdcfc749cfb3d831b5cd4e (patch)
tree2e8855c5c85e8c3fbfa0474fc8107ade8eefd632
parenta37b267792050688791782daed65fc5d3565589f (diff)
Use reallocarray() instead of calloc() when making a copy of the
environment. We already explicitly NULL terminate the array.
-rw-r--r--usr.sbin/cron/env.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.sbin/cron/env.c b/usr.sbin/cron/env.c
index 8fa993ac447..ff9f1c9251d 100644
--- a/usr.sbin/cron/env.c
+++ b/usr.sbin/cron/env.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: env.c,v 1.24 2014/10/08 04:20:57 deraadt Exp $ */
+/* $OpenBSD: env.c,v 1.25 2015/01/14 18:28:15 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@@ -25,7 +25,7 @@
char **
env_init(void) {
- char **p = (char **) malloc(sizeof(char **));
+ char **p = malloc(sizeof(char **));
if (p != NULL)
p[0] = NULL;
@@ -48,7 +48,7 @@ env_copy(char **envp) {
for (count = 0; envp[count] != NULL; count++)
continue;
- p = (char **) calloc(count+1, sizeof(char *)); /* 1 for the NULL */
+ p = reallocarray(NULL, count+1, sizeof(char *)); /* 1 for the NULL */
if (p != NULL) {
for (i = 0; i < count; i++)
if ((p[i] = strdup(envp[i])) == NULL) {