summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-05-31 13:28:09 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-06-01 13:22:44 +0200
commit923c45bdcaebf317ce84a4bfb3fa39beae1bf952 (patch)
treeecc9d93fe372157ea63b2756aa29f1ae0457745b
parent744f9016c44d26c2c3f23f4fb24276d6e46eaa58 (diff)
downloadphp-git-923c45bdcaebf317ce84a4bfb3fa39beae1bf952.tar.gz
Fix #79650: php-win.exe 100% cpu lockup
As of PHP 7.3.0, `sapi_cli_single_write()` is supposed to return `< 0` on failure, but `fwrite()` returns a `size_t`, and signals error by setting the stream's error indicator. We have to cater to that.
-rw-r--r--NEWS2
-rw-r--r--sapi/cli/php_cli.c3
2 files changed, 5 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index e41d3be4ea..e73dbc5867 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.3.20
+- Core:
+ . Fixed bug #79650 (php-win.exe 100% cpu lockup). (cmb)
?? ??? ????, PHP 7.3.19
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 342c5e5feb..2b6ace754c 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -279,6 +279,9 @@ PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /*
} while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO));
#else
ret = fwrite(str, 1, MIN(str_length, 16384), stdout);
+ if (ret == 0 && ferror(stdout)) {
+ return -1;
+ }
#endif
return ret;
}