diff options
| author | Tjerk Meesters <datibbaw@php.net> | 2014-03-03 05:56:22 +0800 |
|---|---|---|
| committer | Tjerk Meesters <datibbaw@php.net> | 2014-03-03 05:56:22 +0800 |
| commit | bbd0781b3993dc6a06c5706c4a8d0754be0c70b9 (patch) | |
| tree | 3e590c68f1e1c67b2bc0fb3677cf45df97abccb7 /ext/standard/proc_open.c | |
| parent | 3eb8102348ed63ad82b3a558d0ae1ea6452e0e58 (diff) | |
| parent | 1533f98afddee259444c00a2dea86029002e5cf7 (diff) | |
| download | php-git-bbd0781b3993dc6a06c5706c4a8d0754be0c70b9.tar.gz | |
Merge branch 'PHP-5.4' into PHP-5.5
Diffstat (limited to 'ext/standard/proc_open.c')
| -rw-r--r-- | ext/standard/proc_open.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 1e37e64563..f4c3b4738c 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -112,8 +112,17 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS; zend_hash_move_forward_ex(target_hash, &pos)) { - convert_to_string_ex(element); - el_len = Z_STRLEN_PP(element); + if (Z_TYPE_PP(element) != IS_STRING) { + zval tmp; + + MAKE_COPY_ZVAL(element, &tmp); + convert_to_string(&tmp); + el_len = Z_STRLEN(tmp); + + zval_dtor(&tmp); + } else { + el_len = Z_STRLEN_PP(element); + } if (el_len == 0) { continue; } @@ -125,7 +134,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent if (string_length == 0) { continue; } - sizeenv += string_length+1; + sizeenv += string_length; break; } } @@ -138,19 +147,26 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent for (zend_hash_internal_pointer_reset_ex(target_hash, &pos); zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS; zend_hash_move_forward_ex(target_hash, &pos)) { + zval tmp; - convert_to_string_ex(element); - el_len = Z_STRLEN_PP(element); + if (Z_TYPE_PP(element) != IS_STRING) { + MAKE_COPY_ZVAL(element, &tmp); + convert_to_string(&tmp); + } else { + tmp = **element; + } + + el_len = Z_STRLEN(tmp); if (el_len == 0) { - continue; + goto next_element; } - data = Z_STRVAL_PP(element); + data = Z_STRVAL(tmp); switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) { case HASH_KEY_IS_STRING: if (string_length == 0) { - continue; + goto next_element; } l = string_length + el_len + 1; @@ -175,6 +191,11 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent case HASH_KEY_NON_EXISTENT: break; } + +next_element: + if (Z_TYPE_PP(element) != IS_STRING) { + zval_dtor(&tmp); + } } assert((uint)(p - env.envp) <= sizeenv); |
