]> granicus.if.org Git - php/commitdiff
Patch for Bug #64544.
authorKeyur Govande <keyur@php.net>
Fri, 29 Mar 2013 14:27:36 +0000 (14:27 +0000)
committerKeyur Govande <keyur@php.net>
Fri, 29 Mar 2013 14:27:36 +0000 (14:27 +0000)
The process title change module keeps track of the locally allocated
environ, so it doesn't need to worry about when environ changes
underneath it, for example by putenv()/setenv()

sapi/cli/php_cli.c
sapi/cli/ps_title.c

index 4b8bae7f78a9cc0a9f9b0157297e8e8e1d2a20d0..729052334d6c97341fdc529bacae125ea3eded0c 100644 (file)
@@ -1402,7 +1402,7 @@ out:
         * Do not move this de-initialization. It needs to happen right before
         * exiting.
         */
-        cleanup_ps_args(argv);
+       cleanup_ps_args(argv);
        exit(exit_status);
 }
 /* }}} */
index a2e47f0316562f320ea5b64c5c9fa4370287169b..730a31b11e784a629f300b27ffa2c3cba587ccb1 100644 (file)
@@ -124,6 +124,11 @@ static size_t ps_buffer_cur_len; /* actual string length in ps_buffer */
 static int save_argc;
 static char** save_argv;
 
+/* 
+ * This holds the 'locally' allocated environ from the save_ps_args method.
+ * This is subsequently free'd at exit.
+ */
+static char** new_environ;
 
 /*
  * Call this method early, before any code has used the original argv passed in
@@ -145,7 +150,6 @@ char** save_ps_args(int argc, char** argv)
     {
         char* end_of_area = NULL;
         int non_contiguous_area = 0;
-        char** new_environ;
         int i;
 
         /*
@@ -405,9 +409,9 @@ void cleanup_ps_args(char **argv)
 #ifdef PS_USE_CLOBBER_ARGV
         {
             int i;
-            for (i = 0; environ[i] != NULL; i++)
-                free(environ[i]);
-            free(environ);
+            for (i = 0; new_environ[i] != NULL; i++)
+                free(new_environ[i]);
+            free(new_environ);
         }
 #endif /* PS_USE_CLOBBER_ARGV */