]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
env_clean(): Try yet another way that appears to work better.
authorTimo Sirainen <tss@iki.fi>
Tue, 10 Jun 2008 04:27:19 +0000 (07:27 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 10 Jun 2008 04:27:19 +0000 (07:27 +0300)
--HG--
branch : HEAD

src/lib/env-util.c

index e4ed8956809aa57fe85ce42d66787f49b02b9024..e8b178561bf671060604f7cf119d1857d88b9a1e 100644 (file)
@@ -24,13 +24,15 @@ void env_clean(void)
                i_fatal("clearenv() failed");
 #else
        extern char **environ;
+       static char *emptyenv[1] = { NULL };
 
-       /* Try to clear the environment. It should always be non-NULL, but
-          apparently it's not on some ancient OSes (Ultrix), so just keep
-          the check. The clearing also fails on FreeBSD 7.0 (currently). */
-       if (environ != NULL)
-               *environ = 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.
+       */
+       environ = emptyenv;
 #endif
        /* don't clear the env_pool, otherwise the environment would get
           corrupted if we failed to clear it. */