]> granicus.if.org Git - php/commitdiff
Fixed bug #49847 (exec() fails to return data inside 2nd parameter, given output...
authorIlia Alshanetsky <iliaa@php.net>
Wed, 14 Oct 2009 01:32:07 +0000 (01:32 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 14 Oct 2009 01:32:07 +0000 (01:32 +0000)
ext/standard/exec.c

index 1fd528f4b26cbfe126ad44223d3a20bb96b2d2a5..fa29cb2124d2236227991b633626de2259c8d3c5 100644 (file)
@@ -130,13 +130,16 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
                }
                if (bufl) {
                        /* strip trailing whitespaces if we have not done so already */
-                       if (type != 2) {
+                       if ((type == 2 && bufl && !l) || type != 2) {
                                l = bufl;
                                while (l-- && isspace(((unsigned char *)buf)[l]));
                                if (l != (bufl - 1)) {
                                        bufl = l + 1;
                                        buf[bufl] = '\0';
                                }
+                               if (type == 2) {
+                                       add_next_index_stringl(array, buf, bufl, 1);
+                               }
                        }
 
                        /* Return last line from the shell command */