Conversation
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()
|
Merged this pull request. |
|
@keyurdg the frozen_environ is needed,, otherwise when a item in env is update, you will get invalid free. <?php
putenv("HOME=/tmp");
var_dump(getenv("HOME"));
putenv("FOO=BAR");
var_dump(getenv("FOO"));I will commit my patch.. thanks |
|
@laruence Great catch, I now realized my mistake. For anyone else curious: putenv() will create a whole new environment if the 'key' doesn't already exist in the current environment and replace the global variable "environ" with this newly created one. To correctly handle the free'ing around the environ allocated by ps_title, new_environ is needed. Or if the key does exist, putenv() will replace the pointer in the global environ with the string pointer passed in. To ensure correctness, frozen_environ stores a list of all strings alloc'ed by ps_title.c and frees them all at the end. |
|
yes, and more important is, zif_putenv passes in a string that is emalloced, if cleanup_ps_args attempt to free it -> invalid free |
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()