diff options
Diffstat (limited to 'ext/pcntl/pcntl.c')
-rw-r--r-- | ext/pcntl/pcntl.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 63751d4b17..300de1e7d4 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -967,6 +967,7 @@ PHP_FUNCTION(pcntl_exec) if (ZEND_NUM_ARGS() > 1) { /* Build argument list */ + SEPARATE_ARRAY(args); args_hash = Z_ARRVAL_P(args); argc = zend_hash_num_elements(args_hash); @@ -975,20 +976,25 @@ PHP_FUNCTION(pcntl_exec) current_arg = argv+1; ZEND_HASH_FOREACH_VAL(args_hash, element) { if (argi >= argc) break; - convert_to_string_ex(element); + if (!try_convert_to_string(element)) { + efree(argv); + return; + } + *current_arg = Z_STRVAL_P(element); argi++; current_arg++; } ZEND_HASH_FOREACH_END(); - *(current_arg) = NULL; + *current_arg = NULL; } else { argv = emalloc(2 * sizeof(char *)); - *argv = path; - *(argv+1) = NULL; + argv[0] = path; + argv[1] = NULL; } if ( ZEND_NUM_ARGS() == 3 ) { /* Build environment pair list */ + SEPARATE_ARRAY(envs); envs_hash = Z_ARRVAL_P(envs); envc = zend_hash_num_elements(envs_hash); @@ -1001,7 +1007,12 @@ PHP_FUNCTION(pcntl_exec) zend_string_addref(key); } - convert_to_string_ex(element); + if (!try_convert_to_string(element)) { + zend_string_release(key); + efree(argv); + efree(envp); + return; + } /* Length of element + equal sign + length of key + null */ pair_length = Z_STRLEN_P(element) + ZSTR_LEN(key) + 2; |