From: Timo Sirainen Date: Tue, 10 Jun 2008 17:28:48 +0000 (+0300) Subject: env_clean(): calloc() is probably the safest way to do it. X-Git-Tag: 1.2.alpha1~354 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b5ddfa1dca9341e7c2c7facf99d557c52fb6c66;p=thirdparty%2Fdovecot%2Fcore.git env_clean(): calloc() is probably the safest way to do it. --HG-- branch : HEAD --- diff --git a/src/lib/env-util.c b/src/lib/env-util.c index e8b178561b..52721e5f15 100644 --- a/src/lib/env-util.c +++ b/src/lib/env-util.c @@ -24,15 +24,15 @@ void env_clean(void) i_fatal("clearenv() failed"); #else extern char **environ; - static char *emptyenv[1] = { NULL }; /* Try to clear the environment. a) environ = NULL crashes on OS X. b) *environ = NULL doesn't work on FreeBSD 7.0. - c) environ = emptyenv appears to work everywhere. + c) environ = emptyenv doesn't work on Haiku OS + d) environ = calloc() should work everywhere */ - environ = emptyenv; + environ = calloc(1, sizeof(*environ)); #endif /* don't clear the env_pool, otherwise the environment would get corrupted if we failed to clear it. */