]> granicus.if.org Git - php/commitdiff
Fix type-o that broke ZTS build
authorJason Greene <jason@php.net>
Mon, 6 May 2002 19:48:39 +0000 (19:48 +0000)
committerJason Greene <jason@php.net>
Mon, 6 May 2002 19:48:39 +0000 (19:48 +0000)
Fix 3 nasty crash bugs that could occur if pcntl_exec's call to execve errored

ext/pcntl/pcntl.c

index aa5a90d28c5cd70eaf21eb85ce6511be846a5996..4fdbd1f15c0a74c165b88a3214f37ea80545acfe 100755 (executable)
@@ -396,6 +396,8 @@ PHP_FUNCTION(pcntl_exec)
                for ( zend_hash_internal_pointer_reset(args_hash), current_arg = argv+1; 
                        (argi < argc && (zend_hash_get_current_data(args_hash, (void **) &element) == SUCCESS));
                        (argi++, current_arg++, zend_hash_move_forward(args_hash)) ) {
+
+                       convert_to_string_ex(element);
                        *current_arg = Z_STRVAL_PP(element);
                }
                *(current_arg) = NULL;
@@ -424,6 +426,9 @@ PHP_FUNCTION(pcntl_exec)
                                        pair--;
                                        continue;
                        }
+
+                       convert_to_string_ex(element);
+
                        /* Length of element + equal sign + length of key + null */ 
                        pair_length = Z_STRLEN_PP(element) + key_length + 2;
                        *pair = emalloc(pair_length);
@@ -439,14 +444,16 @@ PHP_FUNCTION(pcntl_exec)
        
        if (execve(path, argv, envp) == -1) {
                php_error(E_WARNING, "Error has occured in %s: (errno %d) %s",
-                                 get_active_function_name(TSRMLS_CC), errno, strerror(errno));
+                                 get_active_function_name(TSRMLS_C), errno, strerror(errno));
        }
        
        /* Cleanup */
-       for (pair = envp; *pair != NULL; pair++) efree(*pair);
-       
+       if (envp != NULL) {
+               for (pair = envp; *pair != NULL; pair++) efree(*pair);
+               free_alloca(envp);
+       }
+
        free_alloca(argv);
-       free_alloca(envp);
        
        RETURN_FALSE;
 }