}
if (bufl) {
/* strip trailing whitespaces if we have not done so already */
- if ((type == 2 && bufl && !l) || type != 2) {
+ if ((type == 2 && buf != b) || type != 2) {
l = bufl;
while (l-- && isspace(((unsigned char *)buf)[l]));
if (l != (bufl - 1)) {
--- /dev/null
+--TEST--
+Bug #49847 (exec() fails on lines larger then 4095 bytes)
+--FILE--
+<?php
+exec("printf %4098d 1", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(4098) " 1"
+}
--- /dev/null
+--TEST--
+Bug #50732 (exec() adds single byte twice to $output array)
+--FILE--
+<?php
+exec("echo x", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "x"
+}