]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
process_title_init(): Don't assert-crash with empty environment.
authorTimo Sirainen <tss@iki.fi>
Sat, 10 Jul 2010 18:44:45 +0000 (19:44 +0100)
committerTimo Sirainen <tss@iki.fi>
Sat, 10 Jul 2010 18:44:45 +0000 (19:44 +0100)
src/lib/process-title.c

index 42e55ebaccee620f90d1954f3bceafb0271bfa89..e7bfa1390e295c4e6a5b2cf4fad7f293330be9a9 100644 (file)
@@ -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];