From: Timo Sirainen Date: Sat, 10 Jul 2010 18:44:45 +0000 (+0100) Subject: process_title_init(): Don't assert-crash with empty environment. X-Git-Tag: 2.0.rc3~92 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a07b1d77c546256eebda95b7c403e92e1bbcbe94;p=thirdparty%2Fdovecot%2Fcore.git process_title_init(): Don't assert-crash with empty environment. --- diff --git a/src/lib/process-title.c b/src/lib/process-title.c index 42e55ebacc..e7bfa1390e 100644 --- a/src/lib/process-title.c +++ b/src/lib/process-title.c @@ -26,8 +26,6 @@ static void proctitle_hack_init(char *argv[], char *env[]) 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 @@ static void proctitle_hack_init(char *argv[], char *env[]) 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];