Right now the only known issue is GNUTLS's lib_deinit():
e = getenv("GNUTLS_NO_EXPLICIT_INIT");
But we likely never want that to be set. Alternative ways to solve this are
more annoying than our clearing the environment. Libraries probably shouldn't
rely on it much anyway, because some parts of Dovecot clear the whole
environment while running.
void process_title_deinit(void)
{
#ifdef PROCTITLE_HACK
+ char ***environ_p = env_get_environ_p();
+
free(argv_memblock);
free(environ_memblock);
+
+ /* Environment is no longer usable. Make sure we won't crash in case
+ some library's deinit function still calls getenv(). This code was
+ mainly added because of GNUTLS where we don't really care about the
+ getenv() call.
+
+ Alternatively we could remove the free() calls above, but that would
+ annoy memory leak checking tools. Also we could attempt to restore
+ the environ_p to its original state, but that's a bit complicated. */
+ *environ_p = NULL;
#endif
}