Skip to content

Commit b2a760f

Browse files
committed
Merge branch 'pull-request/313' into PHP-5.5
* pull-request/313: Patch for Bug #64544. 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()
2 parents 00d961c + 5bf6323 commit b2a760f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

sapi/cli/php_cli.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ int main(int argc, char *argv[])
14021402
* Do not move this de-initialization. It needs to happen right before
14031403
* exiting.
14041404
*/
1405-
cleanup_ps_args(argv);
1405+
cleanup_ps_args(argv);
14061406
exit(exit_status);
14071407
}
14081408
/* }}} */

sapi/cli/ps_title.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ static size_t ps_buffer_cur_len; /* actual string length in ps_buffer */
124124
static int save_argc;
125125
static char** save_argv;
126126

127+
/*
128+
* This holds the 'locally' allocated environ from the save_ps_args method.
129+
* This is subsequently free'd at exit.
130+
*/
131+
static char** new_environ;
127132

128133
/*
129134
* 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)
145150
{
146151
char* end_of_area = NULL;
147152
int non_contiguous_area = 0;
148-
char** new_environ;
149153
int i;
150154

151155
/*
@@ -405,9 +409,9 @@ void cleanup_ps_args(char **argv)
405409
#ifdef PS_USE_CLOBBER_ARGV
406410
{
407411
int i;
408-
for (i = 0; environ[i] != NULL; i++)
409-
free(environ[i]);
410-
free(environ);
412+
for (i = 0; new_environ[i] != NULL; i++)
413+
free(new_environ[i]);
414+
free(new_environ);
411415
}
412416
#endif /* PS_USE_CLOBBER_ARGV */
413417

0 commit comments

Comments
 (0)