dovecot-2.0: process_title_init(): Don't assert-crash with empty...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jul 10 21:44:48 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/77f244924009
changeset: 11784:77f244924009
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jul 10 19:44:45 2010 +0100
description:
process_title_init(): Don't assert-crash with empty environment.

diffstat:

 src/lib/process-title.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (31 lines):

diff -r 068c54732c96 -r 77f244924009 src/lib/process-title.c
--- a/src/lib/process-title.c	Sat Jul 10 18:35:53 2010 +0100
+++ b/src/lib/process-title.c	Sat Jul 10 19:44:45 2010 +0100
@@ -26,8 +26,6 @@
 	unsigned int i;
 	bool clear_env;
 
-	i_assert(env[0] != NULL);
-
 	/* find the last argv or environment string. it should always be the
 	   last string in environ, but don't rely on it. this is what openssh
 	   does, so hopefully it's safe enough. */
@@ -36,10 +34,14 @@
 		if (argv[i] == last)
 			last = argv[i] + strlen(argv[i]) + 1;
 	}
-	clear_env = last == env[0];
-	for (i = 0; env[i] != NULL; i++) {
-		if (env[i] == last)
-			last = env[i] + strlen(env[i]) + 1;
+	if (env[0] == NULL)
+		clear_env = FALSE;
+	else {
+		clear_env = last == env[0];
+		for (i = 0; env[i] != NULL; i++) {
+			if (env[i] == last)
+				last = env[i] + strlen(env[i]) + 1;
+		}
 	}
 
 	process_title = argv[0];


More information about the dovecot-cvs mailing list