dovecot-1.1: env_clean(): calloc() is probably the safest way to...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 10 20:28:52 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/4cbac2c2d291
changeset: 7626:4cbac2c2d291
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 10 20:28:25 2008 +0300
description:
env_clean(): calloc() is probably the safest way to do it.

diffstat:

1 file changed, 3 insertions(+), 3 deletions(-)
src/lib/env-util.c |    6 +++---

diffs (22 lines):

diff -r 0d7ea59a0dfa -r 4cbac2c2d291 src/lib/env-util.c
--- a/src/lib/env-util.c	Tue Jun 10 20:07:13 2008 +0300
+++ b/src/lib/env-util.c	Tue Jun 10 20:28:25 2008 +0300
@@ -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. */


More information about the dovecot-cvs mailing list