diff options
Diffstat (limited to 'ext/standard/exec.c')
-rw-r--r-- | ext/standard/exec.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 3fcca46a6..6c2dd6000 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -16,7 +16,7 @@ | Ilia Alshanetsky <iliaa@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: exec.c,v 1.113.2.3.2.1.2.17 2009/04/30 15:25:37 pajoye Exp $ */ +/* $Id: exec.c 289688 2009-10-15 21:36:42Z pajoye $ */ #include <stdio.h> #include "php.h" @@ -62,7 +62,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_ { FILE *fp; char *buf, *tmp=NULL; - int l, pclose_return; + int l = 0, pclose_return; char *cmd_p, *b, *c, *d=NULL; php_stream *stream; size_t buflen, bufl = 0; @@ -157,13 +157,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 != (int)(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 */ |